Skip to content

Commit

Permalink
Current version of Psi+ is 1.5.1949
Browse files Browse the repository at this point in the history
It is based on:
* psi: 6b5ba1c6
* plugins: 7a65467
* psimedia: 478567e
* resources: e32ef4b
  • Loading branch information
tehnick committed Jun 6, 2024
1 parent ef7b18e commit 223d205
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 10 deletions.
2 changes: 1 addition & 1 deletion iris/src/xmpp/xmpp-im/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void Client::setCapsOptimizationAllowed(bool allowed) { d->capsOptimization = al

bool Client::capsOptimizationAllowed() const
{
if (d->capsOptimization && d->active && d->serverInfoManager->features().hasCapsOptimize()) {
if (d->capsOptimization && d->active && d->serverInfoManager->server_features().hasCapsOptimize()) {
auto it = d->resourceList.find(d->resource);
return it != d->resourceList.end() && it->status().isAvailable();
}
Expand Down
2 changes: 1 addition & 1 deletion iris/src/xmpp/xmpp-im/xmpp_externalservicediscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ ExternalServiceDiscovery::ExternalServiceDiscovery(Client *client) : client_(cli

bool ExternalServiceDiscovery::isSupported() const
{
return client_->serverInfoManager()->features().test("urn:xmpp:extdisco:2");
return client_->serverInfoManager()->server_features().test("urn:xmpp:extdisco:2");
}

void ExternalServiceDiscovery::services(QObject *ctx, ServicesCallback &&callback, std::chrono::minutes minTtl,
Expand Down
6 changes: 6 additions & 0 deletions iris/src/xmpp/xmpp-im/xmpp_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,12 @@ bool Features::hasCapsOptimize() const { return test(QStringList() << QLatin1Str
#define NS_DIRECT_MUC_INVITE "jabber:x:conference"
bool Features::hasDirectMucInvite() const { return test(QStringList() << QLatin1String(NS_DIRECT_MUC_INVITE)); }

#define FID_AVATAR_TO_VCARD_CONVERSION "urn:xmpp:pep-vcard-conversion:0"
bool Features::hasAvatarConversion() const
{
return test(QStringList() << QLatin1String(FID_AVATAR_TO_VCARD_CONVERSION));
}

// custom Psi actions
#define FID_ADD "psi:add"

Expand Down
1 change: 1 addition & 0 deletions iris/src/xmpp/xmpp-im/xmpp_features.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Features {
bool hasCaps() const;
bool hasCapsOptimize() const;
bool hasDirectMucInvite() const;
bool hasAvatarConversion() const;

[[deprecated]] inline bool canRegister() const { return hasRegister(); }
[[deprecated]] inline bool canSearch() const { return hasSearch(); }
Expand Down
7 changes: 4 additions & 3 deletions iris/src/xmpp/xmpp-im/xmpp_serverinfomanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,12 +266,12 @@ void ServerInfoManager::server_disco_finished()
{
JT_DiscoInfo *jt = static_cast<JT_DiscoInfo *>(sender());
if (jt->success()) {
_features = jt->item().features();
_server_features = jt->item().features();

if (_features.hasMulticast())
if (_server_features.hasMulticast())
_multicastService = _client->jid().domain();

_canMessageCarbons = _features.hasMessageCarbons();
_canMessageCarbons = _server_features.hasMessageCarbons();

auto servInfo
= jt->item().findExtension(XData::Data_Result, QLatin1String("http://jabber.org/network/serverinfo"));
Expand All @@ -297,6 +297,7 @@ void ServerInfoManager::account_disco_finished()
if (i.category == "pubsub" && i.type == "pep")
_hasPEP = true;
}
_account_features = jt->item().features();

emit featuresChanged();
}
Expand Down
6 changes: 4 additions & 2 deletions iris/src/xmpp/xmpp-im/xmpp_serverinfomanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ class ServerInfoManager : public QObject {

const QString &multicastService() const;
bool hasPEP() const;
inline const Features &features() const { return _features; }
inline const Features &server_features() const { return _server_features; }
inline const Features &account_features() const { return _account_features; }
bool canMessageCarbons() const;
inline const QMap<QString, QStringList> &extraServerInfo() const { return _extraServerInfo; }

Expand Down Expand Up @@ -126,7 +127,8 @@ private slots:
private:
XMPP::Client *_client = nullptr;
CapsSpec _caps;
Features _features;
Features _server_features;
Features _account_features;
QString _multicastService;
QMap<QString, QStringList> _extraServerInfo; // XEP-0128, XEP-0157

Expand Down
13 changes: 12 additions & 1 deletion psi.doap
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource='https://xmpp.org/extensions/xep-0084.html'/>
<xmpp:status>complete</xmpp:status>
<xmpp:status>partial</xmpp:status>
<xmpp:version>1.1.4</xmpp:version>
<xmpp:note xml:lang='en'>Loading avatars from URLs is not supported at the moment.</xmpp:note>
</xmpp:SupportedXep>
</implements>

Expand Down Expand Up @@ -740,6 +742,15 @@
</xmpp:SupportedXep>
</implements>

<!-- XEP-0398: User Avatar to vCard-Based Avatars Conversion -->
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource='https://xmpp.org/extensions/xep-0398.html'/>
<xmpp:status>complete</xmpp:status>
<xmpp:version>1.0.0</xmpp:version>
</xmpp:SupportedXep>
</implements>

<!-- XEP-0414: Cryptographic Hash Function Recommendations for XMPP -->
<implements>
<xmpp:SupportedXep>
Expand Down
9 changes: 9 additions & 0 deletions src/avatars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "pixmaputil.h"
#include "psiaccount.h"
#include "vcardfactory.h"
#include "xmpp/xmpp-im/xmpp_serverinfomanager.h"

#include <QBuffer>
#include <QDateTime>
Expand Down Expand Up @@ -1064,7 +1065,15 @@ void AvatarFactory::publish_success(const QString &n, const PubSubItem &item)
info_el.setAttribute("type", image2type(d->selfAvatarData_));
meta_el.appendChild(info_el);
account()->pepManager()->publish(PEP_AVATAR_METADATA_NS, PubSubItem(d->selfAvatarHash_, meta_el));
if (account()->client()->serverInfoManager()->account_features().hasAvatarConversion()) {
VCardFactory::instance()->setPhoto(account()->jid(), d->selfAvatarData_, {});
}
d->selfAvatarData_.clear(); // we don't need it anymore
} else if (n == PEP_AVATAR_METADATA_NS) {
bool removed = item.payload().firstChildElement("metadata").firstChildElement("info").isNull();
if (account()->client()->serverInfoManager()->account_features().hasAvatarConversion() && removed) {
VCardFactory::instance()->deletePhoto(account()->jid(), {});
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/psiaccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ void PsiAccount::serverFeaturesChanged()
j->go(true);
}

if (d->client->serverInfoManager()->features().hasVCard() && !d->vcardChecked) {
if (d->client->serverInfoManager()->server_features().hasVCard() && !d->vcardChecked) {
// Get the vcard
const VCard vcard = VCardFactory::instance()->vcard(d->jid);
if (PsiOptions::instance()->getOption("options.vcard.query-own-vcard-on-login").toBool() || vcard.isEmpty()
Expand Down
34 changes: 34 additions & 0 deletions src/vcardfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,40 @@ VCardRequest *VCardFactory::getVCard(PsiAccount *account, const Jid &jid, Flags
return queuedLoader_->enqueue(account, jid, flags, QueuedLoader::HighPriority);
}

void VCardFactory::setPhoto(const Jid &j, const QByteArray &photo, Flags flags)
{
VCard vc;
Jid sj;
if (flags & MucUser) {
sj = j;
vc = mucVcard(j);
} else {
sj = j.withResource({});
vc = vcard(sj);
}
if (vc && vc.photo() != photo) {
vc.setPhoto({});
saveVCard(sj, vc, flags);
}
}

void VCardFactory::deletePhoto(const Jid &j, Flags flags)
{
VCard vc;
Jid sj;
if (flags & MucUser) {
sj = j;
vc = mucVcard(j);
} else {
sj = j.withResource({});
vc = vcard(sj);
}
if (vc && !vc.photo().isEmpty()) {
vc.setPhoto({});
saveVCard(sj, vc, flags);
}
}

void VCardFactory::ensureVCardPhotoUpdated(PsiAccount *acc, const Jid &jid, Flags flags, const QByteArray &newPhotoHash)
{
VCard vc;
Expand Down
3 changes: 3 additions & 0 deletions src/vcardfactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class VCardFactory : public QObject {
JT_VCard *setVCard(const PsiAccount *account, const VCard &v, const Jid &targetJid, VCardFactory::Flags flags);
VCardRequest *getVCard(PsiAccount *account, const Jid &, VCardFactory::Flags flags = {});

void setPhoto(const Jid &j, const QByteArray &photo, Flags flags);
void deletePhoto(const Jid &j, Flags flags);

// 1. check if it's needed to do a request,
// 2. enqueue request if necessary (no vcard, or if hash doesn't match)
// 3. vcardChanged() will be sent as usually when vcard is updated
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.1947 (2024-06-06, a7848ee9)
1.5.1949 (2024-06-06, 6b5ba1c6)

0 comments on commit 223d205

Please sign in to comment.