Fix contacts not showing : avoid using default friends list that can be set to the ldap_friends list (if we get ldap before having any contacts).
This commit is contained in:
parent
8193c8a4c7
commit
940227dc92
4 changed files with 32 additions and 16 deletions
|
|
@ -99,7 +99,7 @@ FriendCore::FriendCore(const std::shared_ptr<linphone::Friend> &contact) : QObje
|
|||
mStarred = false;
|
||||
}
|
||||
|
||||
mIsLdap = ToolModel::friendIsInLdapFriendList(contact);
|
||||
mIsLdap = ToolModel::friendIsInFriendList(ToolModel::getLdapFriendList(), contact);
|
||||
connect(this, &FriendCore::addressChanged, &FriendCore::allAddressesChanged);
|
||||
connect(this, &FriendCore::phoneNumberChanged, &FriendCore::allAddressesChanged);
|
||||
}
|
||||
|
|
@ -636,7 +636,7 @@ void FriendCore::save() { // Save Values to model
|
|||
mVCardString = mFriendModel->getVCardAsString();
|
||||
auto carddavListForNewFriends = SettingsModel::getCarddavListForNewFriends();
|
||||
auto listWhereToAddFriend = carddavListForNewFriends != nullptr ? carddavListForNewFriends
|
||||
: core->getDefaultFriendList();
|
||||
: ToolModel::getAppFriendList();
|
||||
bool created = (listWhereToAddFriend->addFriend(contact) == linphone::FriendList::Status::OK);
|
||||
if (created) {
|
||||
listWhereToAddFriend->updateSubscriptions();
|
||||
|
|
|
|||
|
|
@ -276,21 +276,33 @@ bool ToolModel::isLocal(const std::shared_ptr<linphone::Conference> &conference,
|
|||
return deviceAddress->equal(gruuAddress);
|
||||
}
|
||||
|
||||
std::shared_ptr<linphone::FriendList> ToolModel::getLdapFriendList() {
|
||||
std::shared_ptr<linphone::FriendList> ToolModel::getFriendList(const std::string &listName) {
|
||||
auto core = CoreModel::getInstance()->getCore();
|
||||
auto ldapFriendList = core->getFriendListByName("ldap_friends");
|
||||
if (!ldapFriendList) {
|
||||
ldapFriendList = core->createFriendList();
|
||||
ldapFriendList->setDisplayName("ldap_friends");
|
||||
core->addFriendList(ldapFriendList);
|
||||
auto friendList = core->getFriendListByName(listName);
|
||||
if (!friendList) {
|
||||
friendList = core->createFriendList();
|
||||
friendList->setDisplayName(listName);
|
||||
core->addFriendList(friendList);
|
||||
}
|
||||
return ldapFriendList;
|
||||
return friendList;
|
||||
}
|
||||
|
||||
bool ToolModel::friendIsInLdapFriendList(const std::shared_ptr<linphone::Friend> &f) {
|
||||
auto ldapFriendList = getLdapFriendList();
|
||||
for (auto ldapFriend : ldapFriendList->getFriends()) {
|
||||
if (f == ldapFriend) return true;
|
||||
std::shared_ptr<linphone::FriendList> ToolModel::getAppFriendList() {
|
||||
return getFriendList("app_friends");
|
||||
}
|
||||
|
||||
std::shared_ptr<linphone::FriendList> ToolModel::getLdapFriendList() {
|
||||
return getFriendList("ldap_friends");
|
||||
}
|
||||
|
||||
bool ToolModel::friendIsInFriendList(const std::shared_ptr<linphone::FriendList> &friendList,
|
||||
const std::shared_ptr<linphone::Friend> &f) {
|
||||
for (auto contact : friendList->getFriends()) {
|
||||
if (f == contact) {
|
||||
qWarning() << Utils::coreStringToAppString(f->getAddress()->asStringUriOnly()) << " / "
|
||||
<< Utils::coreStringToAppString(contact->getAddress()->asStringUriOnly());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,8 +59,12 @@ public:
|
|||
linphone::MediaEncryption = linphone::MediaEncryption::None,
|
||||
QString *errorMessage = nullptr);
|
||||
|
||||
static std::shared_ptr<linphone::FriendList> getFriendList(const std::string &listName);
|
||||
static std::shared_ptr<linphone::FriendList> getAppFriendList();
|
||||
static std::shared_ptr<linphone::FriendList> getLdapFriendList();
|
||||
static bool friendIsInLdapFriendList(const std::shared_ptr<linphone::Friend> &f);
|
||||
|
||||
static bool friendIsInFriendList(const std::shared_ptr<linphone::FriendList> &friendList,
|
||||
const std::shared_ptr<linphone::Friend> &f);
|
||||
|
||||
private:
|
||||
DECLARE_ABSTRACT_OBJECT
|
||||
|
|
|
|||
|
|
@ -371,7 +371,7 @@ VariantObject *Utils::findAvatarByAddress(const QString &address) {
|
|||
if (!data) return nullptr;
|
||||
data->makeRequest([address]() -> QVariant {
|
||||
QString avatar;
|
||||
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
|
||||
auto defaultFriendList = ToolModel::getAppFriendList();
|
||||
if (!defaultFriendList) return QVariant();
|
||||
auto linphoneAddr = ToolModel::interpretUrl(address);
|
||||
auto linFriend = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
|
||||
|
|
@ -399,7 +399,7 @@ VariantObject *Utils::getFriendAddressSecurityLevel(const QString &address) {
|
|||
VariantObject *data = new VariantObject();
|
||||
if (!data) return nullptr;
|
||||
data->makeRequest([address]() {
|
||||
auto defaultFriendList = CoreModel::getInstance()->getCore()->getDefaultFriendList();
|
||||
auto defaultFriendList = ToolModel::getAppFriendList();
|
||||
if (!defaultFriendList) return QVariant();
|
||||
auto linphoneAddr = ToolModel::interpretUrl(address);
|
||||
auto linFriend = CoreModel::getInstance()->getCore()->findFriend(linphoneAddr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue