Skip to content

Commit

Permalink
Ignore vcard's photo in infodlg. just take it from avatar factory
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Jun 13, 2024
1 parent dccdff2 commit 5d12929
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 26 deletions.
35 changes: 10 additions & 25 deletions src/infodlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/vcardfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit 5d12929

Please sign in to comment.