From 5d129299aad0497559c1e0b8fe8c39abca156788 Mon Sep 17 00:00:00 2001 From: Sergei Ilinykh Date: Thu, 13 Jun 2024 21:47:54 +0300 Subject: [PATCH] Ignore vcard's photo in infodlg. just take it from avatar factory --- src/infodlg.cpp | 35 ++++++++++------------------------- src/vcardfactory.cpp | 2 +- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/infodlg.cpp b/src/infodlg.cpp index cc419857b..0108f5d04 100644 --- a/src/infodlg.cpp +++ b/src/infodlg.cpp @@ -452,32 +452,17 @@ void InfoWidget::setData(const VCard4::VCard &i) m_ui.le_role->setText(i.role()); m_ui.te_desc->setPlainText(i.note()); - d->photo = i.photo(); - if (!d->photo.isEmpty()) { - if (!updatePhoto()) { - clearPhoto(); - } + auto pix = d->pa->avatarFactory()->getAvatar(d->jid); + if (pix.isNull()) { + clearPhoto(); } else { - bool usePubsubAvatar - = (d->type == Contact && d->pa->client()->capsManager()->features(d->jid).hasAvatarConversion()) - || (d->type == Self && d->pa->client()->serverInfoManager()->accountFeatures().hasAvatarConversion()); - if (usePubsubAvatar) { - // it has to be always updated in avatars cache - auto pix = d->pa->avatarFactory()->getAvatar(d->jid); - if (pix.isNull()) { - clearPhoto(); - } else { - // yes we could use pixmap directly. let's keep it for future code optimization - QByteArray ba; - QBuffer b(&ba); - b.open(QIODevice::WriteOnly); - pix.toImage().save(&b, "PNG"); - d->photo = ba; - updatePhoto(); - } - } else { - clearPhoto(); - } + // yes we could use pixmap directly. let's keep it for future code optimization + QByteArray ba; + QBuffer b(&ba); + b.open(QIODevice::WriteOnly); + pix.toImage().save(&b, "PNG"); + d->photo = ba; + updatePhoto(); } setEdited(false); diff --git a/src/vcardfactory.cpp b/src/vcardfactory.cpp index 157d76c1a..250568d65 100644 --- a/src/vcardfactory.cpp +++ b/src/vcardfactory.cpp @@ -236,7 +236,7 @@ VCard4::VCard VCardFactory::vcard(const Jid &j, Flags flags) */ Task *VCardFactory::setVCard(PsiAccount *account, const VCard4::VCard &v, const Jid &targetJid, Flags flags) { - if ((flags & MucRoom) || !account->client()->serverInfoManager()->hasPersistentStorage()) { + if ((flags & MucRoom)) { // || !account->client()->serverInfoManager()->hasPersistentStorage()) { JT_VCard *jtVCard_ = new JT_VCard(account->client()->rootTask()); connect(jtVCard_, &JT_VCard::finished, this, [this, v, jtVCard_, flags]() { if (jtVCard_->success()) {