Skip to content

Commit

Permalink
Current version of Psi+ is 1.5.2063
Browse files Browse the repository at this point in the history
It is based on:
* psi: 723e747e
* plugins: 347230b
* psimedia: 478567e
* resources: fc4cfc1
  • Loading branch information
tehnick committed Oct 13, 2024
1 parent 72eccc1 commit cbcb9e3
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 23 deletions.
9 changes: 6 additions & 3 deletions iris/src/xmpp/xmpp-im/httpfileupload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,12 @@ void HttpFileUpload::start()
}
if (ver != XEP0363::vUnknown) {
QVector<std::pair<HttpHost, int>> hosts;
const XData::Field field = item.registeredExtension(xmlns).getField(QLatin1String("max-file-size"));
if (field.isValid() && field.type() == XData::Field::Field_TextSingle)
sizeLimit = field.value().at(0).toULongLong();
auto optField = item.registeredExtension(xmlns).findField(QLatin1String("max-file-size"));
if (optField) {
const XData::Field &field = *optField;
if (field.isValid() && field.type() == XData::Field::Field_TextSingle)
sizeLimit = field.value().value(0).toULongLong();
}
HttpHost host;
host.ver = ver;
host.jid = item.jid();
Expand Down
10 changes: 6 additions & 4 deletions iris/src/xmpp/xmpp-im/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2902,20 +2902,22 @@ CaptchaChallenge::CaptchaChallenge(const Message &m) : d(new CaptchaChallengePri
d->dt = QDateTime::currentDateTime();
}

if (m.getForm().registrarType() != "urn:xmpp:captcha" || m.getForm().type() != XData::Data_Form)
if (m.getForm().registrarType() != QLatin1String("urn:xmpp:captcha") || m.getForm().type() != XData::Data_Form
|| m.id().isEmpty())
return;

if (m.id().isEmpty() || m.getForm().getField("challenge").value().value(0) != m.id())
auto fieldOpt = m.getForm().findField("challenge");
if (!fieldOpt || fieldOpt->value().value(0) != m.id())
return;

if (m.getForm().getField("from").value().value(0).isEmpty())
if (fieldOpt = m.getForm().findField("from"); !fieldOpt || fieldOpt->value().value(0).isEmpty())
return;

d->form = m.getForm();
d->explanation = m.body();
d->urls = m.urlList();
d->arbiter = m.from();
d->offendedJid = Jid(m.getForm().getField("from").value().value(0));
d->offendedJid = Jid(fieldOpt->value().value(0));
}

CaptchaChallenge::~CaptchaChallenge() { }
Expand Down
3 changes: 2 additions & 1 deletion iris/src/xmpp/xmpp-im/xmpp_vcard4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,8 @@ void VCard::setPhoto(const PAdvUris &photo)
Item<UriValue> &VCard::setPhoto(const UriValue &photo)
{
INIT_D();
d->photo.append({ Parameters(), photo });
PAdvUris l = { { PAdvUri { Parameters(), photo } } };
d->photo = std::move(l);
return d->photo.last();
}

Expand Down
10 changes: 8 additions & 2 deletions iris/src/xmpp/xmpp-im/xmpp_xdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void XData::setRegistrarType(const QString &registrarType) { d->registrarType =

const XData::FieldList &XData::fields() const { return d->fields; }

XData::Field XData::getField(const QString &var) const
std::optional<XMPP::XData::Field> XMPP::XData::findField(const QString &var) const
{
if (!d->fields.isEmpty()) {
FieldList::ConstIterator it = d->fields.begin();
Expand All @@ -348,7 +348,13 @@ XData::Field XData::getField(const QString &var) const
return f;
}
}
return Field();
return {};
}

XData::Field XData::getField(const QString &var) const
{
auto of = findField(var);
return of ? *of : XData::Field {};
}

XData::Field &XData::fieldRef(const QString &var)
Expand Down
11 changes: 8 additions & 3 deletions iris/src/xmpp/xmpp-im/xmpp_xdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <QString>
#include <QStringList>

#include <optional>

class QDomDocument;
class QDomElement;

Expand Down Expand Up @@ -152,9 +154,12 @@ class XData {
typedef QList<Field> FieldList;

const FieldList &fields() const;
Field getField(const QString &var) const;
Field &fieldRef(const QString &var);
void setFields(const FieldList &fl);

std::optional<Field> findField(const QString &var) const;
Field getField(const QString &var) const;
Field &fieldRef(const QString &var); // dangerous

void setFields(const FieldList &fl);

private:
class Private : public QSharedData {
Expand Down
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
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.2062 (2024-10-13, 32ac661d)
1.5.2063 (2024-10-13, 723e747e)

0 comments on commit cbcb9e3

Please sign in to comment.