From 1a74863d624e2813a9d0009ab98be40f426707ce Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 30 Jul 2023 14:21:31 +0300 Subject: Jabber: fix for storing dynamic features --- plugins/Jingle/src/voip.cpp | 2 +- protocols/JabberG/src/jabber_caps.cpp | 28 ++++++++++++++++------------ protocols/JabberG/src/jabber_proto.h | 1 + 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/plugins/Jingle/src/voip.cpp b/plugins/Jingle/src/voip.cpp index bd5e541499..bb330277b4 100644 --- a/plugins/Jingle/src/voip.cpp +++ b/plugins/Jingle/src/voip.cpp @@ -484,7 +484,7 @@ bool CJabberAccount::VOIPCallIinitiate(MCONTACT hContact) jid.AppendFormat("/%s", szResource.get()); bool bFound = false; ptrA szFeatures(m_api->GetResourceFeatures(jid)); - for (auto *p = szFeatures.get(); *p; p += mir_strlen(p)) + for (auto *p = szFeatures.get(); *p; p += mir_strlen(p)+1) if (!mir_strcmp(p, JABBER_FEAT_JINGLE)) bFound = true; diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index 852ba4e935..77a7ed9ac9 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -112,18 +112,9 @@ void CJabberProto::OnIqResultCapsDiscoInfo(const TiXmlElement*, CJabberIqInfo *p if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && query) { JabberCapsBits jcbCaps = 0; - for (auto *feature : TiXmlFilter(query, "feature")) { - const char *featureName = XmlGetAttr(feature, "var"); - if (!featureName) - continue; - - for (auto &it : g_JabberFeatCapPairs) { - if (!mir_strcmp(it.szFeature, featureName)) { - jcbCaps |= it.jcbCap; - break; - } - } - } + for (auto *feature : TiXmlFilter(query, "feature")) + if (auto *featureName = XmlGetAttr(feature, "var")) + jcbCaps += GetFeatureCaps(featureName); // no XEP-0115 support? store info & exit CJabberClientPartialCaps *pCaps = r->m_pCaps; @@ -329,6 +320,19 @@ bool CJabberProto::HandleCapsInfoRequest(const TiXmlElement *, CJabberIqInfo *pI return true; } +JabberCapsBits CJabberProto::GetFeatureCaps(const char *pszFeature) +{ + for (auto &it : g_JabberFeatCapPairs) + if (!mir_strcmp(it.szFeature, pszFeature)) + return it.jcbCap; + + for (auto &it : m_lstJabberFeatCapPairsDynamic) + if (!mir_strcmp(it->szFeature, pszFeature)) + return it->jcbCap; + + return 0; +} + JabberCapsBits CJabberProto::GetOwnCaps(bool IncludeDynamic) { JabberCapsBits jcb = JABBER_CAPS_MIRANDA_ALL; diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index d08408df93..0e568605b6 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -426,6 +426,7 @@ struct CJabberProto : public PROTO, public IJabberInterface void RequestOldCapsInfo(pResourceStatus &r, const char *fullJid); void UpdateFeatHash(); + JabberCapsBits GetFeatureCaps(const char *pszFeature); JabberCapsBits GetTotalJidCapabilities(const char *jid); JabberCapsBits GetResourceCapabilities(const char *jid); JabberCapsBits GetResourceCapabilities(const char *jid, pResourceStatus &r); -- cgit v1.2.3