Skip to content

Commit

Permalink
Don't reset muc avatar for old servers compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Oct 13, 2024
1 parent 32ac661 commit 723e747
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
16 changes: 12 additions & 4 deletions src/groupchatdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,15 +1380,23 @@ void GCMainDlg::discoInfoFinished()
d->discoMucName = i.first().name;
}
auto x = t->item().findExtension(XData::Data_Result, QLatin1String("http://jabber.org/protocol/muc#roominfo"));
d->discoMucDescription = x.getField("muc#roominfo_description").value().value(0);
d->discoMucDescription = x.getField(QLatin1String("muc#roominfo_description")).value().value(0);
if (d->mucNameSource >= Private::TitleDisco) {
updateMucName();
}
if (!d->gcSelfPresenceSupported) {
if (t->item().features().hasVCard()) {
auto avatarHash = x.getField("muc#roominfo_avatarhash").value().value(0);
account()->avatarFactory()->ensureVCardUpdated(jid(), QByteArray::fromHex(avatarHash.toLatin1()),
AvatarFactory::MucRoom);
// xep-0486 says either we have "muc#roominfo_avatarhash" with valid hash
// or don't have "muc#roominfo_avatarhash" at all and no avatar correspondingly.
// unfortunatelly we also have old server without this stuff in disco.
// So we are going to update avatar factory only we have "muc#roominfo_avatarhash".
// A drawback of this is inability to reset avatar by room configuration update notification.
auto field = x.findField(QLatin1String("muc#roominfo_avatarhash"));
if (field) {
auto avatarHash = field->value().value(0);
account()->avatarFactory()->ensureVCardUpdated(jid(), QByteArray::fromHex(avatarHash.toLatin1()),
AvatarFactory::MucRoom);
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/options/opt_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void OptionsTabPlugins::listPlugins()
item->setToolTip(C_NAME, toolTip);
item->setCheckState(C_NAME, state);
if (!enabled && !icon.isNull()) {
icon = QIcon(icon.pixmap(icon.availableSizes().at(0), QIcon::Disabled));
icon = QIcon(icon.pixmap(icon.availableSizes().value(0), QIcon::Disabled));
}
item->setIcon(C_NAME, icon);

Expand Down Expand Up @@ -178,7 +178,7 @@ void OptionsTabPlugins::itemChanged(QTreeWidgetItem *item, int column)
d->tw_Plugins->itemWidget(item, C_ABOUT)->setEnabled(enabled);
QIcon icon = pm->icon(name);
if (!enabled && !icon.isNull()) {
icon = QIcon(icon.pixmap(icon.availableSizes().at(0), QIcon::Disabled));
icon = QIcon(icon.pixmap(icon.availableSizes().value(0), QIcon::Disabled));
}
item->setIcon(C_NAME, icon);
d->tw_Plugins->blockSignals(false); // Release signals blocking
Expand Down
4 changes: 2 additions & 2 deletions src/psichatdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void PsiChatDlg::initToolButtons()
ui_.vboxLayout1->addLayout(hb3a);
// -- typeahead

ActionList *list = account()->psi()->actionList()->actionLists(PsiActionList::Actions_Chat).at(0);
ActionList *list = account()->psi()->actionList()->actionLists(PsiActionList::Actions_Chat).value(0);
for (const QString &name : list->actions()) {
auto action = list->copyAction(name, this);
actions_->addAction(name, action);
Expand Down Expand Up @@ -569,7 +569,7 @@ void PsiChatDlg::initToolButtons()
}
}

list = account()->psi()->actionList()->actionLists(PsiActionList::Actions_Common).at(0);
list = account()->psi()->actionList()->actionLists(PsiActionList::Actions_Common).value(0);
for (const QString &name : list->actions()) {
IconAction *action = list->copyAction(name, this);
actions_->addAction(name, action);
Expand Down
2 changes: 1 addition & 1 deletion src/vcardfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void VCardFactory::ensureVCardPhotoUpdated(PsiAccount *acc, const Jid &jid, Flag
if (!vc || vc.photo().isEmpty()) { // we didn't have it and still don't
return;
}
vc.setPhoto(VCard4::UriValue {}); // reset photo;
vc.setPhoto(VCard4::PAdvUris {}); // reset photo;
saveVCard(jid, vc, flags);

return;
Expand Down

0 comments on commit 723e747

Please sign in to comment.