Commit ffc180d0 authored by Anthony Léonard's avatar Anthony Léonard Committed by Nicolas Jager

make addContact() preserve profile::Type

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: default avatarNicolas Jäger <>
parent 9e6743a3
......@@ -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 {
// 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);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment