Skip to content

Commit 64e9997

Browse files
committed
XEP-0398 support: avatar to vcard conversion
1 parent 40c0d7e commit 64e9997

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

src/xmpp/xmpp-im/client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ void Client::setCapsOptimizationAllowed(bool allowed) { d->capsOptimization = al
286286

287287
bool Client::capsOptimizationAllowed() const
288288
{
289-
if (d->capsOptimization && d->active && d->serverInfoManager->features().hasCapsOptimize()) {
289+
if (d->capsOptimization && d->active && d->serverInfoManager->server_features().hasCapsOptimize()) {
290290
auto it = d->resourceList.find(d->resource);
291291
return it != d->resourceList.end() && it->status().isAvailable();
292292
}

src/xmpp/xmpp-im/xmpp_externalservicediscovery.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ ExternalServiceDiscovery::ExternalServiceDiscovery(Client *client) : client_(cli
250250

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

256256
void ExternalServiceDiscovery::services(QObject *ctx, ServicesCallback &&callback, std::chrono::minutes minTtl,

src/xmpp/xmpp-im/xmpp_features.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ bool Features::hasCapsOptimize() const { return test(QStringList() << QLatin1Str
214214
#define NS_DIRECT_MUC_INVITE "jabber:x:conference"
215215
bool Features::hasDirectMucInvite() const { return test(QStringList() << QLatin1String(NS_DIRECT_MUC_INVITE)); }
216216

217+
#define FID_AVATAR_TO_VCARD_CONVERSION "urn:xmpp:pep-vcard-conversion:0"
218+
bool Features::hasAvatarConversion() const
219+
{
220+
return test(QStringList() << QLatin1String(FID_AVATAR_TO_VCARD_CONVERSION));
221+
}
222+
217223
// custom Psi actions
218224
#define FID_ADD "psi:add"
219225

src/xmpp/xmpp-im/xmpp_features.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Features {
5959
bool hasCaps() const;
6060
bool hasCapsOptimize() const;
6161
bool hasDirectMucInvite() const;
62+
bool hasAvatarConversion() const;
6263

6364
[[deprecated]] inline bool canRegister() const { return hasRegister(); }
6465
[[deprecated]] inline bool canSearch() const { return hasSearch(); }

src/xmpp/xmpp-im/xmpp_serverinfomanager.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,12 @@ void ServerInfoManager::server_disco_finished()
266266
{
267267
JT_DiscoInfo *jt = static_cast<JT_DiscoInfo *>(sender());
268268
if (jt->success()) {
269-
_features = jt->item().features();
269+
_server_features = jt->item().features();
270270

271-
if (_features.hasMulticast())
271+
if (_server_features.hasMulticast())
272272
_multicastService = _client->jid().domain();
273273

274-
_canMessageCarbons = _features.hasMessageCarbons();
274+
_canMessageCarbons = _server_features.hasMessageCarbons();
275275

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

301302
emit featuresChanged();
302303
}

src/xmpp/xmpp-im/xmpp_serverinfomanager.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ class ServerInfoManager : public QObject {
8080

8181
const QString &multicastService() const;
8282
bool hasPEP() const;
83-
inline const Features &features() const { return _features; }
83+
inline const Features &server_features() const { return _server_features; }
84+
inline const Features &account_features() const { return _account_features; }
8485
bool canMessageCarbons() const;
8586
inline const QMap<QString, QStringList> &extraServerInfo() const { return _extraServerInfo; }
8687

@@ -126,7 +127,8 @@ private slots:
126127
private:
127128
XMPP::Client *_client = nullptr;
128129
CapsSpec _caps;
129-
Features _features;
130+
Features _server_features;
131+
Features _account_features;
130132
QString _multicastService;
131133
QMap<QString, QStringList> _extraServerInfo; // XEP-0128, XEP-0157
132134

0 commit comments

Comments
 (0)