summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-10-28 19:03:01 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-10-28 19:03:01 +0300
commit21aaad51c5e0bcf7157bd8e37e6e8ee0d1e55525 (patch)
treeaa87b18bcf00431ae2bacf6ca2a0a738efa2ced6
parent005bde628864f2335445aab8c1b8f42d62da25d4 (diff)
Jabber: we store now server caps in our cache not to rerequest them on each login
-rwxr-xr-xprotocols/JabberG/src/jabber_iqid.cpp40
-rwxr-xr-xprotocols/JabberG/src/jabber_thread.cpp11
-rwxr-xr-xprotocols/JabberG/src/stdafx.h2
3 files changed, 39 insertions, 14 deletions
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index d2c77698eb..3a58341074 100755
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "jabber_caps.h"
#include "jabber_privacy.h"
-void CJabberProto::OnIqResultServerDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo*)
+void CJabberProto::OnIqResultServerDiscoInfo(const TiXmlElement *iqNode, CJabberIqInfo *pInfo)
{
if (iqNode == nullptr)
return;
@@ -62,21 +62,31 @@ void CJabberProto::OnIqResultServerDiscoInfo(const TiXmlElement *iqNode, CJabber
NotifyFastHook(hDiscoInfoResult, (WPARAM)&tmp, (LPARAM)(IJabberInterface*)this);
}
- if (m_ThreadInfo) {
- for (auto *feature : TiXmlFilter(query, "feature")) {
- const char *featureName = XmlGetAttr(feature, "var");
- if (!featureName)
- continue;
+ JabberCapsBits jcb = 0;
- for (int j = 0; j < g_cJabberFeatCapPairs; j++) {
- if (!mir_strcmp(g_JabberFeatCapPairs[j].szFeature, featureName)) {
- m_ThreadInfo->jabberServerCaps |= g_JabberFeatCapPairs[j].jcbCap;
- break;
- }
+ for (auto *feature : TiXmlFilter(query, "feature")) {
+ const char *featureName = XmlGetAttr(feature, "var");
+ if (!featureName)
+ continue;
+
+ for (int j = 0; j < g_cJabberFeatCapPairs; j++) {
+ if (!mir_strcmp(g_JabberFeatCapPairs[j].szFeature, featureName)) {
+ jcb |= g_JabberFeatCapPairs[j].jcbCap;
+ break;
}
}
}
+ if (void *p = pInfo->GetUserData()) {
+ const char *szNode = (const char *)p;
+ const char *szVer = szNode + strlen(szNode) + 1;
+ g_clientCapsManager.SetClientCaps(szNode, szVer, "", jcb);
+ mir_free(p);
+ }
+
+ if (m_ThreadInfo)
+ m_ThreadInfo->jabberServerCaps |= jcb;
+
OnProcessLoginRq(m_ThreadInfo, JABBER_LOGIN_SERVERINFO);
}
@@ -126,8 +136,8 @@ void CJabberProto::OnProcessLoginRq(ThreadData *info, DWORD rq)
if (info->jabberServerCaps & JABBER_CAPS_ARCHIVE_AUTO)
EnableArchive(m_bEnableMsgArchive != 0);
+ // Server seems to support carbon copies, let's enable/disable them
if (info->jabberServerCaps & JABBER_CAPS_CARBONS)
- // Server seems to support carbon copies, let's enable/disable them
m_ThreadInfo->send(XmlNodeIq("set", SerialNext()) << XCHILDNS((m_bEnableCarbons) ? "enable" : "disable", JABBER_FEAT_CARBONS));
// Server seems to support MAM, let's retrieve MAM settings
@@ -198,7 +208,11 @@ void CJabberProto::OnLoggedIn()
}
m_bPepSupported = false;
- m_ThreadInfo->jabberServerCaps = JABBER_RESOURCE_CAPS_NONE;
+
+ if (m_ThreadInfo->pPendingQuery) {
+ m_ThreadInfo->send(XmlNodeIq(m_ThreadInfo->pPendingQuery) << XQUERY(JABBER_FEAT_DISCO_INFO));
+ m_ThreadInfo->pPendingQuery = nullptr;
+ }
char szBareJid[JABBER_MAX_JID_LEN];
JabberStripJid(m_ThreadInfo->fullJID, szBareJid, _countof(szBareJid));
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 111ef69fb8..01bdddd0eb 100755
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -612,6 +612,8 @@ void CJabberProto::PerformAuthentication(ThreadData *info)
void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info)
{
+ info->jabberServerCaps = JABBER_RESOURCE_CAPS_NONE;
+
bool isRegisterAvailable = false;
bool areMechanismsDefined = false;
@@ -702,6 +704,15 @@ void CJabberProto::OnProcessFeatures(const TiXmlElement *node, ThreadData *info)
m_StrmMgmt.CheckStreamFeatures(n);
else if (!mir_strcmp(pszName, "csi") && n->Attribute("xmlns", JABBER_FEAT_CSI))
m_bCisAvailable = true;
+ else if (!mir_strcmp(pszName, "c") && !mir_strcmp(n->Attribute("xmlns"), JABBER_FEAT_ENTITY_CAPS)) {
+ auto *szNode = n->Attribute("node"), *szHash = n->Attribute("ver");
+ auto *pCaps = g_clientCapsManager.GetPartialCaps(szNode, szHash);
+ if (pCaps == nullptr) {
+ CMStringA payLoad(FORMAT, "%s%c%s", szNode, 0, szHash);
+ info->pPendingQuery = AddIQ(&CJabberProto::OnIqResultServerDiscoInfo, JABBER_IQ_TYPE_GET, info->conn.server, payLoad.Detach(), 1);
+ }
+ else info->jabberServerCaps |= pCaps->GetCaps();
+ }
}
if (areMechanismsDefined) {
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h
index fa4beaab7f..839e2e0cad 100755
--- a/protocols/JabberG/src/stdafx.h
+++ b/protocols/JabberG/src/stdafx.h
@@ -375,9 +375,9 @@ struct ThreadData
char fullJID[JABBER_MAX_JID_LEN];
ptrA tszNewPassword;
-// class TJabberAuth *auth;
char *gssapiHostName;
+ CJabberIqInfo *pPendingQuery;
JabberCapsBits jabberServerCaps;
void close(void);