Skip to content
Snippets Groups Projects
Commit f1ae077f authored by Sébastien Blin's avatar Sébastien Blin
Browse files

contactmodel: slotProfileReceived can return profile for account

Replace profile when account has no avatar and another device
announce an avatar for this account

Change-Id: Iec473380e5e249ab7b069a811eb82468d168e3bb
parent 2d07cf30
No related branches found
No related tags found
No related merge requests found
...@@ -1171,7 +1171,6 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, ...@@ -1171,7 +1171,6 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId,
in.setCodec("UTF-8"); in.setCodec("UTF-8");
auto vCard = in.readAll(); auto vCard = in.readAll();
vCardFile.remove();
profile::Info profileInfo; profile::Info profileInfo;
profileInfo.uri = peer; profileInfo.uri = peer;
...@@ -1183,6 +1182,21 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId, ...@@ -1183,6 +1182,21 @@ ContactModelPimpl::slotProfileReceived(const QString& accountId,
else if (e.contains("FN")) else if (e.contains("FN"))
profileInfo.alias = e.split(":")[1]; profileInfo.alias = e.split(":")[1];
if (peer == linked.owner.profileInfo.uri) {
if (linked.owner.profileInfo.avatar.isEmpty() && !profileInfo.avatar.isEmpty()) {
auto dest = storage::getPath() + accountId + "/profile.vcf";
QFile oldvCard(dest);
if (oldvCard.exists())
oldvCard.remove();
vCardFile.rename(dest);
linked.owner.accountModel->setAlias(linked.owner.id, profileInfo.alias);
linked.owner.accountModel->setAvatar(linked.owner.id, profileInfo.avatar);
emit linked.profileUpdated(peer);
}
return;
}
vCardFile.remove();
contact::Info contactInfo; contact::Info contactInfo;
contactInfo.profileInfo = profileInfo; contactInfo.profileInfo = profileInfo;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment