From ffc180d069309f5f2c27e2c093e6ef9e288159e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthony=20L=C3=A9onard?= <anthony.leonard@savoirfairelinux.com> Date: Mon, 15 Jan 2018 16:04:32 -0500 Subject: [PATCH] make addContact() preserve profile::Type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On non-DBus platform, when trusting a pending contact. The call from daemon to ContactModelPimpl::addToContacts happens before the end of ContactModel::addContact. This has the effect of switching the profile type to RING then back to PENDING. We now ensure that profileInfo.type is set according to the value already present in pimpl_->contacts if any. Change-Id: I4609056fe9191d00affe93ef1223bd06073b2276 Reviewed-by: Nicolas Jäger <nicolas.jager@savoirfairelinux.com> --- src/contactmodel.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/contactmodel.cpp b/src/contactmodel.cpp index faa5ce28..aab2d954 100644 --- a/src/contactmodel.cpp +++ b/src/contactmodel.cpp @@ -219,8 +219,13 @@ ContactModel::addContact(contact::Info contactInfo) auto iter = pimpl_->contacts.find(contactInfo.profileInfo.uri); if (iter == pimpl_->contacts.end()) pimpl_->contacts.emplace_hint(iter, contactInfo.profileInfo.uri, contactInfo); - else + else { + // On non-DBus platform, contactInfo.profileInfo.type may be wrong as the contact + // may be trusted already. We must use Profile::Type from pimpl_->contacts + // and not from contactInfo so we cannot revert a contact back to PENDING. + contactInfo.profileInfo.type = iter->second.profileInfo.type; iter->second.profileInfo = contactInfo.profileInfo; + } emit contactAdded(profile.uri); } -- GitLab