diff options
author | George Hazan <ghazan@miranda.im> | 2017-08-10 19:14:06 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-08-10 19:14:19 +0300 |
commit | 3d83eeec481c25253e2535e7ce9476e3f046123a (patch) | |
tree | c0cc9f3ffc49a79f510fcff8658fb9baaba99605 /protocols | |
parent | e98d9da63ab340e4fdaf2fa2cd4037e4b7f0a498 (diff) |
Jabber:
- more fixes for XEP-115 support;
- obsolete code removed;
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/JabberG/src/jabber_api.cpp | 2 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_caps.cpp | 379 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_caps.h | 73 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_list.h | 9 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_menu.cpp | 6 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_misc.cpp | 52 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_notes.cpp | 2 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.cpp | 29 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.h | 4 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_thread.cpp | 83 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_userinfo.cpp | 65 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_util.cpp | 5 |
12 files changed, 275 insertions, 434 deletions
diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp index 49b36cbb2a..fe4247c359 100644 --- a/protocols/JabberG/src/jabber_api.cpp +++ b/protocols/JabberG/src/jabber_api.cpp @@ -243,7 +243,7 @@ int CJabberProto::RegisterFeature(LPCTSTR szFeature, LPCTSTR szDescription) if (wcschr(L"bcdfghjklmnpqrstvwxz0123456789", *pSrc))
*pDst++ = *pSrc;
*pDst = 0;
- m_clientCapsManager.SetClientCaps(JABBER_CAPS_MIRANDA_NODE, szExt, jcb);
+ m_clientCapsManager.SetOwnCaps(JABBER_CAPS_MIRANDA_NODE, szExt, jcb);
fcp = new JabberFeatCapPairDynamic();
fcp->szExt = szExt; // will be deallocated along with other values of JabberFeatCapPairDynamic in CJabberProto destructor
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index 2ea81003af..4c5afa7a3e 100755 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -83,7 +83,7 @@ const JabberFeatCapPairExt g_JabberFeatCapPairsExt[] = { { JABBER_EXT_SECUREIM, JABBER_CAPS_SECUREIM, "SecureIM/IsContactSecured" },
{ JABBER_EXT_MIROTR, JABBER_CAPS_MIROTR, "MirOTRMenuCheckService" },
{ JABBER_EXT_NEWGPG, JABBER_CAPS_NEWGPG, "/ExportGPGKeys" },
- { JABBER_EXT_OMEMO, JABBER_CAPS_OMEMO, },
+ { JABBER_EXT_OMEMO, JABBER_CAPS_OMEMO, },
{ JABBER_EXT_NUDGE, JABBER_CAPS_ATTENTION, "NUDGE/Send" },
{ JABBER_EXT_JINGLE, JABBER_CAPS_JINGLE, "Jingle/StartSession" },
{ JABBER_EXT_COMMANDS, JABBER_CAPS_COMMANDS },
@@ -92,50 +92,12 @@ const JabberFeatCapPairExt g_JabberFeatCapPairsExt[] = { { JABBER_EXT_USER_TUNE, JABBER_CAPS_USER_TUNE_NOTIFY, "ListeningTo/Enabled" },
{ JABBER_EXT_USER_TUNE, JABBER_CAPS_USER_TUNE_NOTIFY, "WATrack/GetFileInfo" },
{ JABBER_EXT_MIR_NOTES, JABBER_CAPS_MIRANDA_NOTES },
- { szCoreVersion, JABBER_CAPS_MIRANDA_PARTIAL },
+ { szCoreVersion, JABBER_CAPS_MIRANDA_PARTIAL },
{ JABBER_EXT_PLATFORMX86, JABBER_CAPS_PLATFORMX86 },
{ JABBER_EXT_PLATFORMX64, JABBER_CAPS_PLATFORMX64 },
{ NULL }
};
-void CJabberProto::OnIqResultCapsDiscoInfoSI(HXML, CJabberIqInfo *pInfo)
-{
- pResourceStatus r( ResourceInfoFromJID(pInfo->GetFrom()));
- if (r == NULL)
- return;
-
- if (r->m_tszCapsNode == NULL)
- OnIqResultCapsDiscoInfo(NULL, pInfo);
-
- HXML query = pInfo->GetChildNode();
- if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && query) {
- // XEP-0232 support
- HXML xform;
- for (int i = 1; (xform = XmlGetNthChild(query, L"x", i)) != NULL; i++) {
- wchar_t *szFormTypeValue = XPath(xform, L"field[@var='FORM_TYPE']/value");
- if (szFormTypeValue && !mir_wstrcmp(szFormTypeValue, L"urn:xmpp:dataforms:softwareinfo")) {
- wchar_t *szTmp = XPath(xform, L"field[@var='os']/value");
- if (szTmp)
- r->m_tszOs = mir_wstrdup(szTmp);
- szTmp = XPath(xform, L"field[@var='os_version']/value");
- if (szTmp)
- r->m_tszOsVersion = mir_wstrdup(szTmp);
- szTmp = XPath(xform, L"field[@var='software']/value");
- if (szTmp)
- r->m_tszSoftware = mir_wstrdup(szTmp);
- szTmp = XPath(xform, L"field[@var='software_version']/value");
- if (szTmp)
- r->m_tszSoftwareVersion = mir_wstrdup(szTmp);
- szTmp = XPath(xform, L"field[@var='x-miranda-core-version']/value");
- if (szTmp)
- r->m_tszXMirandaCoreVersion = mir_wstrdup(szTmp);
-
- JabberUserInfoUpdate(pInfo->GetHContact());
- }
- }
- }
-}
-
void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo *pInfo)
{
pResourceStatus r(ResourceInfoFromJID(pInfo->GetFrom()));
@@ -143,8 +105,9 @@ void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo *pInfo) HXML query = pInfo->GetChildNode();
if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && query) {
JabberCapsBits jcbCaps = 0;
+
HXML feature;
- for (int i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != NULL; i++) {
+ for (int i = 1; (feature = XmlGetNthChild(query, L"feature", i)) != nullptr; i++) {
const wchar_t *featureName = XmlGetAttrValue(feature, L"var");
if (!featureName)
continue;
@@ -157,21 +120,34 @@ void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo *pInfo) }
}
- // no version info support and no XEP-0115 support?
- if (r && r->m_dwVersionRequestTime == -1 && !r->m_tszSoftwareVersion && !r->m_tszSoftware && !r->m_tszCapsNode) {
- r->m_jcbCachedCaps = jcbCaps;
- r->m_dwDiscoInfoRequestTime = -1;
- return;
- }
+ // no XEP-0115 support?
+ if (r) {
+ if (!r->m_pCaps) {
+ r->m_jcbCachedCaps = jcbCaps;
+ r->m_dwDiscoInfoRequestTime = -1;
+ return;
+ }
+
+ HXML xform;
+ for (int i = 1; (xform = XmlGetNthChild(query, L"x", i)) != NULL; i++) {
+ wchar_t *szFormTypeValue = XPath(xform, L"field[@var='FORM_TYPE']/value");
+ if (!mir_wstrcmp(szFormTypeValue, L"urn:xmpp:dataforms:softwareinfo"))
+ r->m_pCaps->Parse(xform);
+ }
+
+ JabberUserInfoUpdate(pInfo->GetHContact());
- if (r && !m_clientCapsManager.SetClientCaps(pInfo->GetIqId(), jcbCaps))
- r->m_jcbCachedCaps = jcbCaps;
+ if (!m_clientCapsManager.SetClientCaps(pInfo->GetIqId(), jcbCaps))
+ r->m_jcbCachedCaps = jcbCaps;
+
+ UpdateMirVer(pInfo->GetHContact(), r);
+ }
JabberUserInfoUpdate(pInfo->GetHContact());
}
else {
// no version info support and no XEP-0115 support?
- if (r && r->m_dwVersionRequestTime == -1 && !r->m_tszSoftwareVersion && !r->m_tszSoftware && !r->m_tszCapsNode) {
+ if (r && !r->m_pCaps) {
r->m_jcbCachedCaps = JABBER_RESOURCE_CAPS_NONE;
r->m_dwDiscoInfoRequestTime = -1;
}
@@ -195,7 +171,7 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilites(const wchar_t *jid) // get bare jid info only if where is no resources
if (!item || (item && !item->arResources.getCount())) {
- jcbToReturn = GetResourceCapabilites(szBareJid, FALSE);
+ jcbToReturn = GetResourceCapabilites(szBareJid, false);
if (jcbToReturn & JABBER_RESOURCE_CAPS_ERROR)
jcbToReturn = JABBER_RESOURCE_CAPS_NONE;
}
@@ -204,7 +180,7 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilites(const wchar_t *jid) for (int i = 0; i < item->arResources.getCount(); i++) {
wchar_t szFullJid[JABBER_MAX_JID_LEN];
mir_snwprintf(szFullJid, L"%s/%s", szBareJid, item->arResources[i]->m_tszResourceName);
- JabberCapsBits jcb = GetResourceCapabilites(szFullJid, FALSE);
+ JabberCapsBits jcb = GetResourceCapabilites(szFullJid, false);
if (!(jcb & JABBER_RESOURCE_CAPS_ERROR))
jcbToReturn |= jcb;
}
@@ -212,7 +188,7 @@ JabberCapsBits CJabberProto::GetTotalJidCapabilites(const wchar_t *jid) return jcbToReturn;
}
-JabberCapsBits CJabberProto::GetResourceCapabilites(const wchar_t *jid, BOOL appendBestResource)
+JabberCapsBits CJabberProto::GetResourceCapabilites(const wchar_t *jid, bool appendBestResource)
{
wchar_t fullJid[JABBER_MAX_JID_LEN];
if (appendBestResource)
@@ -225,30 +201,30 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const wchar_t *jid, BOOL app return JABBER_RESOURCE_CAPS_ERROR;
// XEP-0115 mode
- if (r->m_tszCapsNode && r->m_tszCapsVer) {
+ if (r->m_pCaps) {
+ CJabberClientPartialCaps *pCaps = r->m_pCaps;
JabberCapsBits jcbCaps = 0, jcbExtCaps = 0;
- BOOL bRequestSent = FALSE;
- JabberCapsBits jcbMainCaps = m_clientCapsManager.GetClientCaps(r->m_tszCapsNode, r->m_tszCapsVer);
+ bool bRequestSent = false;
+ JabberCapsBits jcbMainCaps = pCaps->GetCaps();
if (jcbMainCaps == JABBER_RESOURCE_CAPS_TIMEOUT && !r->m_dwDiscoInfoRequestTime)
jcbMainCaps = JABBER_RESOURCE_CAPS_ERROR;
if (jcbMainCaps == JABBER_RESOURCE_CAPS_UNINIT) {
// send disco#info query
-
CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
- m_clientCapsManager.SetClientCaps(r->m_tszCapsNode, r->m_tszCapsVer, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
+ pCaps->SetCaps(JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
r->m_dwDiscoInfoRequestTime = pInfo->GetRequestTime();
wchar_t queryNode[512];
- mir_snwprintf(queryNode, L"%s#%s", r->m_tszCapsNode, r->m_tszCapsVer);
+ mir_snwprintf(queryNode, L"%s#%s", pCaps->GetNode(), pCaps->GetHash());
m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR(L"node", queryNode));
- bRequestSent = TRUE;
+ bRequestSent = true;
}
else if (jcbMainCaps == JABBER_RESOURCE_CAPS_IN_PROGRESS)
- bRequestSent = TRUE;
+ bRequestSent = true;
else if (jcbMainCaps != JABBER_RESOURCE_CAPS_TIMEOUT)
jcbCaps |= jcbMainCaps;
@@ -257,7 +233,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const wchar_t *jid, BOOL app wchar_t *token = wcstok(caps, L" ");
while (token) {
- switch (jcbExtCaps = m_clientCapsManager.GetClientCaps(r->m_tszCapsNode, token)) {
+ switch (jcbExtCaps = m_clientCapsManager.GetClientCaps(pCaps->GetNode(), token)) {
case JABBER_RESOURCE_CAPS_ERROR:
break;
@@ -267,10 +243,9 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const wchar_t *jid, BOOL app CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
- m_clientCapsManager.SetClientCaps(r->m_tszCapsNode, token, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
+ m_clientCapsManager.SetClientCaps(pCaps->GetNode(), pCaps->GetHash(), token, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
- m_ThreadInfo->send(
- XmlNodeIq(pInfo) << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR(L"node", CMStringW(FORMAT, L"%s#%s", r->m_tszCapsNode, token)));
+ m_ThreadInfo->send(XmlNodeIq(pInfo) << XQUERY(JABBER_FEAT_DISCO_INFO) << XATTR(L"node", CMStringW(FORMAT, L"%s#%s", pCaps->GetNode(), token)));
bRequestSent = TRUE;
}
@@ -296,114 +271,26 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const wchar_t *jid, BOOL app return jcbCaps | r->m_jcbManualDiscoveredCaps;
}
- // capability mode (version request + service discovery)
-
- // no version info:
- if (!r->m_tszSoftwareVersion && !r->m_tszSoftware) {
- // version request not sent:
- if (!r->m_dwVersionRequestTime) {
- // send version query
-
- CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE);
- pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
- r->m_dwVersionRequestTime = pInfo->GetRequestTime();
-
- XmlNodeIq iq(pInfo);
- iq << XQUERY(JABBER_FEAT_VERSION);
- m_ThreadInfo->send(iq);
- return JABBER_RESOURCE_CAPS_IN_PROGRESS;
- }
- // version not received:
- else if (r->m_dwVersionRequestTime != -1) {
- // no timeout?
- if (GetTickCount() - r->m_dwVersionRequestTime < JABBER_RESOURCE_CAPS_QUERY_TIMEOUT)
- return JABBER_RESOURCE_CAPS_IN_PROGRESS;
-
- // timeout
- r->m_dwVersionRequestTime = -1;
- }
- // no version information, try direct service discovery
- if (!r->m_dwDiscoInfoRequestTime) {
- // send disco#info query
-
- CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
- pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
- r->m_dwDiscoInfoRequestTime = pInfo->GetRequestTime();
-
- XmlNodeIq iq(pInfo);
- iq << XQUERY(JABBER_FEAT_DISCO_INFO);
- m_ThreadInfo->send(iq);
-
- return JABBER_RESOURCE_CAPS_IN_PROGRESS;
- }
- else if (r->m_dwDiscoInfoRequestTime == -1)
- return r->m_jcbCachedCaps | r->m_jcbManualDiscoveredCaps;
- else if (GetTickCount() - r->m_dwDiscoInfoRequestTime < JABBER_RESOURCE_CAPS_QUERY_TIMEOUT)
- return JABBER_RESOURCE_CAPS_IN_PROGRESS;
- else
- r->m_dwDiscoInfoRequestTime = -1;
- // version request timeout:
- return JABBER_RESOURCE_CAPS_NONE;
- }
-
- // version info available:
- if (r->m_tszSoftware && r->m_tszSoftwareVersion) {
- JabberCapsBits jcbMainCaps = m_clientCapsManager.GetClientCaps(r->m_tszSoftware, r->m_tszSoftwareVersion);
- if (jcbMainCaps == JABBER_RESOURCE_CAPS_ERROR) {
- // Bombus hack:
- if (!mir_wstrcmp(r->m_tszSoftware, L"Bombus") || !mir_wstrcmp(r->m_tszSoftware, L"BombusMod")) {
- jcbMainCaps = JABBER_CAPS_SI | JABBER_CAPS_SI_FT | JABBER_CAPS_IBB | JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY | JABBER_CAPS_DATA_FORMS | JABBER_CAPS_LAST_ACTIVITY | JABBER_CAPS_VERSION | JABBER_CAPS_COMMANDS | JABBER_CAPS_VCARD_TEMP;
- m_clientCapsManager.SetClientCaps(r->m_tszSoftware, r->m_tszSoftwareVersion, jcbMainCaps);
- }
- // Neos hack:
- else if (!mir_wstrcmp(r->m_tszSoftware, L"neos")) {
- jcbMainCaps = JABBER_CAPS_OOB | JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY | JABBER_CAPS_LAST_ACTIVITY | JABBER_CAPS_VERSION;
- m_clientCapsManager.SetClientCaps(r->m_tszSoftware, r->m_tszSoftwareVersion, jcbMainCaps);
- }
- // sim hack:
- else if (!mir_wstrcmp(r->m_tszSoftware, L"sim")) {
- jcbMainCaps = JABBER_CAPS_OOB | JABBER_CAPS_VERSION | JABBER_CAPS_MESSAGE_EVENTS | JABBER_CAPS_MESSAGE_EVENTS_NO_DELIVERY;
- m_clientCapsManager.SetClientCaps(r->m_tszSoftware, r->m_tszSoftwareVersion, jcbMainCaps);
- }
- }
-
- else if (jcbMainCaps == JABBER_RESOURCE_CAPS_UNINIT) {
- // send disco#info query
-
- CJabberIqInfo *pInfo = AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, fullJid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE);
- pInfo->SetTimeout(JABBER_RESOURCE_CAPS_QUERY_TIMEOUT);
- m_clientCapsManager.SetClientCaps(r->m_tszSoftware, r->m_tszSoftwareVersion, JABBER_RESOURCE_CAPS_IN_PROGRESS, pInfo->GetIqId());
- r->m_dwDiscoInfoRequestTime = pInfo->GetRequestTime();
-
- XmlNodeIq iq(pInfo);
- iq << XQUERY(JABBER_FEAT_DISCO_INFO);
- m_ThreadInfo->send(iq);
-
- jcbMainCaps = JABBER_RESOURCE_CAPS_IN_PROGRESS;
- }
- return jcbMainCaps | r->m_jcbManualDiscoveredCaps;
- }
-
return JABBER_RESOURCE_CAPS_NONE;
}
/////////////////////////////////////////////////////////////////////////////////////////
// CJabberClientPartialCaps class
-CJabberClientPartialCaps::CJabberClientPartialCaps(const wchar_t *szVer)
+CJabberClientPartialCaps::CJabberClientPartialCaps(CJabberClientCaps *pParent, const wchar_t *szHash, const wchar_t *szVer)
+ : m_parent(pParent),
+ m_szHash(mir_wstrdup(szHash)),
+ m_szSoftVer(mir_wstrdup(szVer)),
+ m_jcbCaps(JABBER_RESOURCE_CAPS_UNINIT),
+ m_pNext(nullptr),
+ m_nIqId(-1),
+ m_dwRequestTime(0)
{
- m_szVer = mir_wstrdup(szVer);
- m_jcbCaps = JABBER_RESOURCE_CAPS_UNINIT;
- m_pNext = NULL;
- m_nIqId = -1;
- m_dwRequestTime = 0;
}
CJabberClientPartialCaps::~CJabberClientPartialCaps()
{
- mir_free(m_szVer);
- if (m_pNext)
- delete m_pNext;
+ delete m_pNext;
}
CJabberClientPartialCaps* CJabberClientPartialCaps::SetNext(CJabberClientPartialCaps *pCaps)
@@ -413,7 +300,16 @@ CJabberClientPartialCaps* CJabberClientPartialCaps::SetNext(CJabberClientPartial return pRetVal;
}
-void CJabberClientPartialCaps::SetCaps(JabberCapsBits jcbCaps, int nIqId /*= -1*/)
+void CJabberClientPartialCaps::Parse(HXML xform)
+{
+ m_szOs = mir_wstrdup(XPath(xform, L"field[@var='os']/value"));
+ m_szOsVer = mir_wstrdup(XPath(xform, L"field[@var='os_version']/value"));
+ m_szSoft = mir_wstrdup(XPath(xform, L"field[@var='software']/value"));
+ m_szSoftVer = mir_wstrdup(XPath(xform, L"field[@var='software_version']/value"));
+ m_szSoftMir = mir_wstrdup(XPath(xform, L"field[@var='x-miranda-core-version']/value"));
+}
+
+void CJabberClientPartialCaps::SetCaps(JabberCapsBits jcbCaps, int nIqId)
{
if (jcbCaps == JABBER_RESOURCE_CAPS_IN_PROGRESS)
m_dwRequestTime = GetTickCount();
@@ -432,18 +328,18 @@ JabberCapsBits CJabberClientPartialCaps::GetCaps() return m_jcbCaps;
}
-CJabberClientPartialCaps* CJabberClientCaps::FindByVersion(const wchar_t *szVer)
+CJabberClientPartialCaps* CJabberClientCaps::FindByVersion(const wchar_t *szHash)
{
- if (!m_pCaps || !szVer)
- return NULL;
+ if (m_pCaps == nullptr)
+ return nullptr;
CJabberClientPartialCaps *pCaps = m_pCaps;
while (pCaps) {
- if (!mir_wstrcmp(szVer, pCaps->GetVersion()))
- break;
+ if (!mir_wstrcmp(szHash, pCaps->GetHash()))
+ return pCaps;
pCaps = pCaps->GetNext();
}
- return pCaps;
+ return nullptr;
}
CJabberClientPartialCaps* CJabberClientCaps::FindById(int nIqId)
@@ -463,70 +359,67 @@ CJabberClientPartialCaps* CJabberClientCaps::FindById(int nIqId) /////////////////////////////////////////////////////////////////////////////////////////
// CJabberClientCaps class
-CJabberClientCaps::CJabberClientCaps(const wchar_t *szNode)
+CJabberClientCaps::CJabberClientCaps(const wchar_t *szNode) :
+ m_szNode(mir_wstrdup(szNode))
{
- m_szNode = mir_wstrdup(szNode);
- m_pCaps = NULL;
- m_pNext= NULL;
-}
-
-CJabberClientCaps::~CJabberClientCaps() {
- mir_free(m_szNode);
- if (m_pCaps)
- delete m_pCaps;
- if (m_pNext)
- delete m_pNext;
+ m_pCaps = nullptr;
}
-CJabberClientCaps* CJabberClientCaps::SetNext(CJabberClientCaps *pClient)
+CJabberClientCaps::~CJabberClientCaps()
{
- CJabberClientCaps *pRetVal = m_pNext;
- m_pNext = pClient;
- return pRetVal;
+ mir_free(m_szNode);
+ delete m_pCaps;
}
-JabberCapsBits CJabberClientCaps::GetPartialCaps(wchar_t *szVer)
+JabberCapsBits CJabberClientCaps::GetPartialCaps(const wchar_t *szVer)
{
CJabberClientPartialCaps *pCaps = FindByVersion(szVer);
return (pCaps) ? pCaps->GetCaps() : JABBER_RESOURCE_CAPS_UNINIT;
}
-BOOL CJabberClientCaps::SetPartialCaps(const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId /*= -1*/)
+CJabberClientPartialCaps* CJabberClientCaps::SetPartialCaps(const wchar_t *szHash, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId)
{
- CJabberClientPartialCaps *pCaps = FindByVersion(szVer);
+ CJabberClientPartialCaps *pCaps = FindByVersion(szHash);
if (!pCaps) {
- pCaps = new CJabberClientPartialCaps(szVer);
- if (!pCaps)
- return FALSE;
+ pCaps = new CJabberClientPartialCaps(this, szHash, szVer);
pCaps->SetNext(m_pCaps);
m_pCaps = pCaps;
}
pCaps->SetCaps(jcbCaps, nIqId);
- return TRUE;
+ return pCaps;
}
-BOOL CJabberClientCaps::SetPartialCaps(int nIqId, JabberCapsBits jcbCaps)
+CJabberClientPartialCaps* CJabberClientCaps::SetPartialCaps(int nIqId, JabberCapsBits jcbCaps)
{
CJabberClientPartialCaps *pCaps = FindById(nIqId);
if (!pCaps)
- return FALSE;
+ return nullptr;
pCaps->SetCaps(jcbCaps, -1);
- return TRUE;
+ return pCaps;
}
/////////////////////////////////////////////////////////////////////////////////////////
// CJabberClientCapsManager class
-CJabberClientCapsManager::CJabberClientCapsManager(CJabberProto *proto)
+static int sttCompareNodes(const CJabberClientCaps *p1, const CJabberClientCaps *p2)
+{
+ return mir_wstrcmp(p1->GetNode(), p2->GetNode());
+}
+
+CJabberClientCapsManager::CJabberClientCapsManager(CJabberProto *proto) :
+ m_arCaps(10, sttCompareNodes)
{
ppro = proto;
- m_pClients = NULL;
UpdateFeatHash();
}
+CJabberClientCapsManager::~CJabberClientCapsManager()
+{
+}
+
void CJabberClientCapsManager::UpdateFeatHash()
{
m_szFeaturesCrc.Empty();
@@ -573,39 +466,24 @@ const wchar_t* CJabberClientCapsManager::GetFeaturesCrc() return m_szFeaturesCrc.c_str();
}
-CJabberClientCapsManager::~CJabberClientCapsManager()
-{
- if (m_pClients)
- delete m_pClients;
-}
-
CJabberClientCaps* CJabberClientCapsManager::FindClient(const wchar_t *szNode)
{
- if (!m_pClients || !szNode)
- return NULL;
+ if (szNode == nullptr)
+ return nullptr;
- CJabberClientCaps *pClient = m_pClients;
- while (pClient) {
- if (!mir_wstrcmp(szNode, pClient->GetNode()))
- break;
- pClient = pClient->GetNext();
- }
- return pClient;
+ return m_arCaps.find((CJabberClientCaps*)&szNode);
}
void CJabberClientCapsManager::AddDefaultCaps()
{
- wchar_t szVerWHash[256];
- mir_snwprintf(szVerWHash, 255, L"%s %s", szCoreVersion, m_szFeaturesCrc.c_str());
+ SetOwnCaps(JABBER_CAPS_MIRANDA_NODE, szCoreVersion, ppro->m_options.UseOMEMO ? (JABBER_CAPS_MIRANDA_ALL | JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY) : JABBER_CAPS_MIRANDA_ALL);
- SetClientCaps(JABBER_CAPS_MIRANDA_NODE, szVerWHash, ppro->m_options.UseOMEMO ? (JABBER_CAPS_MIRANDA_ALL | JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY) : JABBER_CAPS_MIRANDA_ALL);
-
- for (int i=0; g_JabberFeatCapPairsExt[i].szFeature; i++)
+ for (int i = 0; g_JabberFeatCapPairsExt[i].szFeature; i++)
if (g_JabberFeatCapPairsExt[i].Valid())
- SetClientCaps(JABBER_CAPS_MIRANDA_NODE, g_JabberFeatCapPairsExt[i].szFeature, g_JabberFeatCapPairsExt[i].jcbCap);
+ SetOwnCaps(JABBER_CAPS_MIRANDA_NODE, g_JabberFeatCapPairsExt[i].szFeature, g_JabberFeatCapPairsExt[i].jcbCap);
}
-JabberCapsBits CJabberClientCapsManager::GetClientCaps(wchar_t *szNode, wchar_t *szVer)
+JabberCapsBits CJabberClientCapsManager::GetClientCaps(const wchar_t *szNode, const wchar_t *szVer)
{
mir_cslockfull lck(m_cs);
CJabberClientCaps *pClient = FindClient(szNode);
@@ -620,54 +498,60 @@ JabberCapsBits CJabberClientCapsManager::GetClientCaps(wchar_t *szNode, wchar_t return jcbCaps;
}
-BOOL CJabberClientCapsManager::SetClientCaps(const wchar_t *szNode, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId /*= -1*/)
+CJabberClientPartialCaps* CJabberClientCapsManager::GetPartialCaps(const wchar_t *szNode, const wchar_t *szHash)
+{
+ mir_cslock lck(m_cs);
+ CJabberClientCaps *pClient = FindClient(szNode);
+ return (pClient == nullptr) ? nullptr : pClient->FindByVersion(szHash);
+}
+
+CJabberClientPartialCaps* CJabberClientCapsManager::SetClientCaps(const wchar_t *szNode, const wchar_t *szHash, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId)
{
mir_cslockfull lck(m_cs);
CJabberClientCaps *pClient = FindClient(szNode);
if (!pClient) {
pClient = new CJabberClientCaps(szNode);
- if (!pClient)
- return FALSE;
-
- pClient->SetNext(m_pClients);
- m_pClients = pClient;
+ m_arCaps.insert(pClient);
}
- BOOL bOk = pClient->SetPartialCaps(szVer, jcbCaps, nIqId);
+
+ CJabberClientPartialCaps *res = pClient->SetPartialCaps(szHash, szVer, jcbCaps, nIqId);
lck.unlock();
ppro->debugLogW(L"CAPS: set caps %I64x for: %s, %s", jcbCaps, szNode, szVer);
- return bOk;
+ return res;
}
-BOOL CJabberClientCapsManager::SetClientCaps(int nIqId, JabberCapsBits jcbCaps)
+CJabberClientPartialCaps* CJabberClientCapsManager::SetClientCaps(int nIqId, JabberCapsBits jcbCaps)
{
mir_cslock lck(m_cs);
- if (!m_pClients)
- return FALSE;
- BOOL bOk = FALSE;
- CJabberClientCaps *pClient = m_pClients;
- while (pClient) {
- if (pClient->SetPartialCaps(nIqId, jcbCaps)) {
+ for (int i = 0; i < m_arCaps.getCount(); i++) {
+ CJabberClientCaps &p = m_arCaps[i];
+ CJabberClientPartialCaps *res = p.SetPartialCaps(nIqId, jcbCaps);
+ if (res != nullptr) {
ppro->debugLogA("CAPS: set caps %I64x for iq %d", jcbCaps, nIqId);
- bOk = TRUE;
- break;
+ return res;
}
- pClient = pClient->GetNext();
}
- return bOk;
+ return nullptr;
}
-BOOL CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, const wchar_t *szNode)
+bool CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, const wchar_t *szNode)
{
int i;
JabberCapsBits jcb = 0;
if (szNode) {
- for (i=0; g_JabberFeatCapPairsExt[i].szFeature; i++) {
+ wchar_t szExtCap[512], szExtCapWHash[560];
+ mir_snwprintf(szExtCap, L"%s#%s", JABBER_CAPS_MIRANDA_NODE, m_szFeaturesCrc.c_str());
+ if (!mir_wstrcmp(szExtCap, szNode)) {
+ szNode = nullptr;
+ goto LBL_All;
+ }
+
+ for (i = 0; g_JabberFeatCapPairsExt[i].szFeature; i++) {
if (!g_JabberFeatCapPairsExt[i].Valid())
continue;
- //TODO: something better here
- wchar_t szExtCap[ 512 ], szExtCapWHash [560];
+ // TODO: something better here
mir_snwprintf(szExtCap, L"%s#%s", JABBER_CAPS_MIRANDA_NODE, g_JabberFeatCapPairsExt[i].szFeature);
mir_snwprintf(szExtCapWHash, L"%s %s", szExtCap, m_szFeaturesCrc.c_str());
if (!mir_wstrcmp(szNode, szExtCap) || !mir_wstrcmp(szNode, szExtCapWHash)) {
@@ -677,9 +561,8 @@ BOOL CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, con }
// check features registered through IJabberNetInterface::RegisterFeature() and IJabberNetInterface::AddFeatures()
- for (i=0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
- //TODO: something better here
- wchar_t szExtCap[ 512 ], szExtCapWHash[560];
+ for (i = 0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++) {
+ // TODO: something better here
mir_snwprintf(szExtCap, L"%s#%s", JABBER_CAPS_MIRANDA_NODE, ppro->m_lstJabberFeatCapPairsDynamic[i]->szExt);
mir_snwprintf(szExtCapWHash, L"%s %s", szExtCap, m_szFeaturesCrc.c_str());
if (!mir_wstrcmp(szNode, szExtCap) || !mir_wstrcmp(szNode, szExtCapWHash)) {
@@ -690,9 +573,10 @@ BOOL CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, con // unknown node, not XEP-0115 request
if (!jcb)
- return FALSE;
+ return false;
}
else {
+LBL_All:
jcb = JABBER_CAPS_MIRANDA_ALL;
for (i=0; i < ppro->m_lstJabberFeatCapPairsDynamic.getCount(); i++)
jcb |= ppro->m_lstJabberFeatCapPairsDynamic[i]->jcbCap;
@@ -739,6 +623,5 @@ BOOL CJabberClientCapsManager::HandleInfoRequest(HXML, CJabberIqInfo *pInfo, con }
ppro->m_ThreadInfo->send(iq);
-
- return TRUE;
+ return true;
}
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h index 503e0f3146..eaf9875891 100755 --- a/protocols/JabberG/src/jabber_caps.h +++ b/protocols/JabberG/src/jabber_caps.h @@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _JABBER_CAPS_H_
#define _JABBER_CAPS_H_
-#include "jabber_iq.h"
-
typedef unsigned __int64 JabberCapsBits;
#define JABBER_RESOURCE_CAPS_QUERY_TIMEOUT 10000
@@ -211,16 +209,16 @@ typedef unsigned __int64 JabberCapsBits; class CJabberClientPartialCaps
{
-
-protected:
- wchar_t *m_szVer;
+ ptrW m_szHash, m_szOs, m_szOsVer, m_szSoft, m_szSoftVer, m_szSoftMir;
JabberCapsBits m_jcbCaps;
- CJabberClientPartialCaps *m_pNext;
int m_nIqId;
DWORD m_dwRequestTime;
+ class CJabberClientCaps *m_parent;
+ CJabberClientPartialCaps *m_pNext;
+
public:
- CJabberClientPartialCaps(const wchar_t *szVer);
+ CJabberClientPartialCaps(CJabberClientCaps *pParent, const wchar_t *szHash, const wchar_t *szVer);
~CJabberClientPartialCaps();
CJabberClientPartialCaps* SetNext(CJabberClientPartialCaps *pCaps);
@@ -228,54 +226,48 @@ public: { return m_pNext;
}
+ void Parse(HXML);
void SetCaps(JabberCapsBits jcbCaps, int nIqId = -1);
JabberCapsBits GetCaps();
- __inline wchar_t* GetVersion()
- { return m_szVer;
- }
+ __inline const wchar_t* GetHash() const { return m_szHash.get(); }
+ __inline const wchar_t* GetNode() const;
- __inline int GetIqId()
- { return m_nIqId;
- }
+ __inline const wchar_t* GetOs() const { return m_szOs.get(); }
+ __inline const wchar_t* GetOsVer() const { return m_szOsVer.get(); }
+ __inline const wchar_t* GetSoft() const { return m_szSoft.get(); }
+ __inline const wchar_t* GetSoftVer() const { return m_szSoftVer.get(); }
+ __inline const wchar_t* GetSoftMir() const { return m_szSoftMir.get(); }
+
+ __inline int GetIqId() const { return m_nIqId; }
};
class CJabberClientCaps
{
-
-protected:
wchar_t *m_szNode;
CJabberClientPartialCaps *m_pCaps;
- CJabberClientCaps *m_pNext;
-
-protected:
- CJabberClientPartialCaps* FindByVersion(const wchar_t *szVer);
- CJabberClientPartialCaps* FindById(int nIqId);
public:
CJabberClientCaps(const wchar_t *szNode);
~CJabberClientCaps();
- CJabberClientCaps* SetNext(CJabberClientCaps *pClient);
- __inline CJabberClientCaps* GetNext()
- { return m_pNext;
- }
+ CJabberClientPartialCaps* FindByVersion(const wchar_t *szHash);
+ CJabberClientPartialCaps* FindById(int nIqId);
- JabberCapsBits GetPartialCaps(wchar_t *szVer);
- BOOL SetPartialCaps(const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
- BOOL SetPartialCaps(int nIqId, JabberCapsBits jcbCaps);
+ JabberCapsBits GetPartialCaps(const wchar_t *szVer);
+ CJabberClientPartialCaps* SetPartialCaps(const wchar_t *szHash, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
+ CJabberClientPartialCaps* SetPartialCaps(int nIqId, JabberCapsBits jcbCaps);
- __inline wchar_t* GetNode()
- { return m_szNode;
- }
+ __inline wchar_t* GetNode() const { return m_szNode; }
};
+__inline const wchar_t* CJabberClientPartialCaps::GetNode() const { return m_parent->GetNode(); }
+
class CJabberClientCapsManager
{
-
-protected:
mir_cs m_cs;
- CJabberClientCaps *m_pClients;
+ OBJLIST<CJabberClientCaps> m_arCaps;
+
CJabberProto *ppro;
CMStringW m_szFeaturesCrc;
@@ -290,11 +282,18 @@ public: const wchar_t* GetFeaturesCrc();
void UpdateFeatHash();
- JabberCapsBits GetClientCaps(wchar_t *szNode, wchar_t *szVer);
- BOOL SetClientCaps(const wchar_t *szNode, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
- BOOL SetClientCaps(int nIqId, JabberCapsBits jcbCaps);
+ JabberCapsBits GetClientCaps(const wchar_t *szNode, const wchar_t *szHash);
+ CJabberClientPartialCaps* GetPartialCaps(const wchar_t *szNode, const wchar_t *szHash);
+
+ CJabberClientPartialCaps* SetClientCaps(const wchar_t *szNode, const wchar_t *szHash, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId = -1);
+ CJabberClientPartialCaps* SetClientCaps(int nIqId, JabberCapsBits jcbCaps);
+
+ __inline CJabberClientPartialCaps* SetOwnCaps(const wchar_t *szNode, const wchar_t *szVer, JabberCapsBits jcbCaps, int nIqId = -1)
+ {
+ return SetClientCaps(szNode, m_szFeaturesCrc, szVer, jcbCaps, nIqId);
+ }
- BOOL HandleInfoRequest(HXML iqNode, CJabberIqInfo *pInfo, const wchar_t *szNode);
+ bool HandleInfoRequest(HXML iqNode, CJabberIqInfo *pInfo, const wchar_t *szNode);
};
struct JabberFeatCapPair
diff --git a/protocols/JabberG/src/jabber_list.h b/protocols/JabberG/src/jabber_list.h index 3b7dab0f29..1d6070ff3d 100644 --- a/protocols/JabberG/src/jabber_list.h +++ b/protocols/JabberG/src/jabber_list.h @@ -102,18 +102,13 @@ public: ptrW m_tszRealJid; // real jid for jabber conferences
// XEP-0115 support
- ptrW m_tszCapsNode;
- ptrW m_tszCapsVer;
+ CJabberClientPartialCaps *m_pCaps;
ptrW m_tszCapsExt;
- DWORD m_dwVersionRequestTime, m_dwDiscoInfoRequestTime;
+ DWORD m_dwDiscoInfoRequestTime;
JabberCapsBits m_jcbCachedCaps;
JabberCapsBits m_jcbManualDiscoveredCaps;
- // XEP-232 support
- ptrW m_tszOs, m_tszOsVersion;
- ptrW m_tszSoftware, m_tszSoftwareVersion, m_tszXMirandaCoreVersion;
-
// XEP-0085 gone event support
BOOL m_bMessageSessionActive;
};
diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index e08731dded..9e7f927559 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -971,10 +971,8 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) if (r && r->m_bMessageSessionActive) {
r->m_bMessageSessionActive = FALSE;
- if (GetResourceCapabilites(jid, TRUE) & JABBER_CAPS_CHATSTATES)
- m_ThreadInfo->send(
- XmlNode(L"message") << XATTR(L"to", jid) << XATTR(L"type", L"chat") << XATTRID(SerialNext())
- << XCHILDNS(L"gone", JABBER_FEAT_CHATSTATES));
+ if (GetResourceCapabilites(jid, true) & JABBER_CAPS_CHATSTATES)
+ m_ThreadInfo->send(XmlNode(L"message") << XATTR(L"to", jid) << XATTR(L"type", L"chat") << XATTRID(SerialNext()) << XCHILDNS(L"gone", JABBER_FEAT_CHATSTATES));
}
}
}
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 6b271d7fca..0f4eae9e81 100755 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -279,59 +279,53 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item) void CJabberProto::FormatMirVer(pResourceStatus &resource, CMStringW &res)
{
res.Empty();
- if (resource == NULL)
+ if (resource == nullptr)
return;
- // jabber:iq:version info requested and exists?
- if (resource->m_dwVersionRequestTime && resource->m_tszSoftware) {
- debugLogW(L"JabberUpdateMirVer: for iq:version rc %s: %s", resource->m_tszResourceName, resource->m_tszSoftware);
- if (!resource->m_tszSoftwareVersion || wcsstr(resource->m_tszSoftware, resource->m_tszSoftwareVersion))
- res = resource->m_tszSoftware;
- else
- res.Format(L"%s %s", resource->m_tszSoftware, resource->m_tszSoftwareVersion);
- }
- // no version info and no caps info? set MirVer = resource name
- else if (!resource->m_tszCapsNode || !resource->m_tszCapsVer) {
+ // no caps info? set MirVer = resource name
+ if (resource->m_pCaps == nullptr) {
debugLogW(L"JabberUpdateMirVer: for rc %s: %s", resource->m_tszResourceName, resource->m_tszResourceName);
if (resource->m_tszResourceName)
res = resource->m_tszResourceName;
}
// XEP-0115 caps mode
else {
- debugLogW(L"JabberUpdateMirVer: for rc %s: %s#%s", resource->m_tszResourceName, resource->m_tszCapsNode, resource->m_tszCapsVer);
-
- int i;
+ CJabberClientPartialCaps *pCaps = resource->m_pCaps;
+ debugLogW(L"JabberUpdateMirVer: for rc %s: %s#%s", resource->m_tszResourceName, pCaps->GetNode(), pCaps->GetHash());
// search through known software list
+ int i;
for (i = 0; i < _countof(sttCapsNodeToName_Map); i++)
- if (wcsstr(resource->m_tszCapsNode, sttCapsNodeToName_Map[i].node)) {
- res.Format(L"%s %s", sttCapsNodeToName_Map[i].name, resource->m_tszCapsVer);
+ if (wcsstr(pCaps->GetNode(), sttCapsNodeToName_Map[i].node)) {
+ res.Format(L"%s %s", sttCapsNodeToName_Map[i].name, pCaps->GetSoftVer());
break;
}
// unknown software
if (i == _countof(sttCapsNodeToName_Map))
- res.Format(L"%s %s", resource->m_tszCapsNode, resource->m_tszCapsVer);
+ res.Format(L"%s %s", pCaps->GetSoft(), pCaps->GetSoftVer());
}
// attach additional info for fingerprint plguin
- if (resource->m_tszCapsExt && wcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX86) && !wcsstr(res, L"x86"))
- res.Append(L" x86");
+ if (resource->m_tszCapsExt) {
+ if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX86) && !wcsstr(res, L"x86"))
+ res.Append(L" x86");
- if (resource->m_tszCapsExt && wcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX64) && !wcsstr(res, L"x64"))
- res.Append(L" x64");
+ if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX64) && !wcsstr(res, L"x64"))
+ res.Append(L" x64");
- if (resource->m_tszCapsExt && wcsstr(resource->m_tszCapsExt, JABBER_EXT_SECUREIM) && !wcsstr(res, L"(SecureIM)"))
- res.Append(L" (SecureIM)");
+ if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_SECUREIM) && !wcsstr(res, L"(SecureIM)"))
+ res.Append(L" (SecureIM)");
- if (resource->m_tszCapsExt && wcsstr(resource->m_tszCapsExt, JABBER_EXT_MIROTR) && !wcsstr(res, L"(MirOTR)"))
- res.Append(L" (MirOTR)");
+ if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_MIROTR) && !wcsstr(res, L"(MirOTR)"))
+ res.Append(L" (MirOTR)");
- if (resource->m_tszCapsExt && wcsstr(resource->m_tszCapsExt, JABBER_EXT_NEWGPG) && !wcsstr(res, L"(New_GPG)"))
- res.Append(L" (New_GPG)");
+ if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_NEWGPG) && !wcsstr(res, L"(New_GPG)"))
+ res.Append(L" (New_GPG)");
- if (resource->m_tszCapsExt && wcsstr(resource->m_tszCapsExt, JABBER_EXT_OMEMO) && !wcsstr(res, L"(omemo)"))
- res.Append(L" (omemo)");
+ if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_OMEMO) && !wcsstr(res, L"(omemo)"))
+ res.Append(L" (omemo)");
+ }
if (resource->m_tszResourceName && !wcsstr(res, resource->m_tszResourceName))
if (wcsstr(res, L"Miranda IM") || wcsstr(res, L"Miranda NG") || m_options.ShowForeignResourceInMirVer)
diff --git a/protocols/JabberG/src/jabber_notes.cpp b/protocols/JabberG/src/jabber_notes.cpp index 733d5d9580..cc73c491e4 100644 --- a/protocols/JabberG/src/jabber_notes.cpp +++ b/protocols/JabberG/src/jabber_notes.cpp @@ -730,7 +730,7 @@ void CJabberProto::ProcessOutgoingNote(CNoteItem *pNote, bool ok) mir_snwprintf(buf, L"Incoming note: %s\n\n%s\nTags: %s",
pNote->GetTitle(), pNote->GetText(), pNote->GetTagsStr());
- JabberCapsBits jcb = GetResourceCapabilites(pNote->GetFrom(), TRUE);
+ JabberCapsBits jcb = GetResourceCapabilites(pNote->GetFrom(), true);
if (jcb & JABBER_RESOURCE_CAPS_ERROR)
jcb = JABBER_RESOURCE_CAPS_NONE;
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 4743906a8a..866bd1b030 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -544,7 +544,7 @@ DWORD_PTR __cdecl CJabberProto::GetCaps(int type, MCONTACT hContact) case PFLAG_MAXCONTACTSPERPACKET:
wchar_t szClientJid[JABBER_MAX_JID_LEN];
if (GetClientJID(hContact, szClientJid, _countof(szClientJid))) {
- JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
+ JabberCapsBits jcb = GetResourceCapabilites(szClientJid, true);
return ((~jcb & JABBER_CAPS_ROSTER_EXCHANGE) ? 0 : 50);
}
}
@@ -602,17 +602,11 @@ int __cdecl CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/) mir_snwprintf(tmp, L"%s/%s", szBareJid, r->m_tszResourceName);
if (r->m_jcbCachedCaps & JABBER_CAPS_DISCO_INFO) {
- XmlNodeIq iq5(AddIQ(&CJabberProto::OnIqResultCapsDiscoInfoSI, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
+ XmlNodeIq iq5(AddIQ(&CJabberProto::OnIqResultCapsDiscoInfo, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_CHILD_TAG_NODE | JABBER_IQ_PARSE_HCONTACT));
iq5 << XQUERY(JABBER_FEAT_DISCO_INFO);
m_ThreadInfo->send(iq5);
}
- if (r->m_dwVersionRequestTime == 0) {
- XmlNodeIq iq4(AddIQ(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
- iq4 << XQUERY(JABBER_FEAT_VERSION);
- m_ThreadInfo->send(iq4);
- }
-
if (!mir_wstrcmp(tmp, jid)) {
XmlNodeIq iq3(AddIQ(&CJabberProto::OnIqResultLastActivity, JABBER_IQ_TYPE_GET, tmp, JABBER_IQ_PARSE_FROM));
iq3 << XQUERY(JABBER_FEAT_LAST_ACTIVITY);
@@ -620,11 +614,6 @@ int __cdecl CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/) }
}
}
- else if (item->getTemp()->m_dwVersionRequestTime == 0) {
- XmlNodeIq iq4(AddIQ(&CJabberProto::OnIqResultVersion, JABBER_IQ_TYPE_GET, item->jid, JABBER_IQ_PARSE_FROM | JABBER_IQ_PARSE_HCONTACT | JABBER_IQ_PARSE_CHILD_TAG_NODE));
- iq4 << XQUERY(JABBER_FEAT_VERSION);
- m_ThreadInfo->send(iq4);
- }
}
}
@@ -783,7 +772,7 @@ int __cdecl CJabberProto::SendContacts(MCONTACT hContact, int, int nContacts, MC if (!GetClientJID(hContact, szClientJid, _countof(szClientJid)))
return 0;
- JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
+ JabberCapsBits jcb = GetResourceCapabilites(szClientJid, true);
if (~jcb & JABBER_CAPS_ROSTER_EXCHANGE)
return 0;
@@ -824,10 +813,10 @@ HANDLE __cdecl CJabberProto::SendFile(MCONTACT hContact, const wchar_t *szDescri if (item->ft != NULL)
return 0;
- JabberCapsBits jcb = GetResourceCapabilites(item->jid, TRUE);
+ JabberCapsBits jcb = GetResourceCapabilites(item->jid, true);
if (jcb == JABBER_RESOURCE_CAPS_IN_PROGRESS) {
Sleep(600);
- jcb = GetResourceCapabilites(item->jid, TRUE);
+ jcb = GetResourceCapabilites(item->jid, true);
}
// fix for very smart clients, like gajim
@@ -983,9 +972,9 @@ int __cdecl CJabberProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) pResourceStatus r(ResourceInfoFromJID(szClientJid));
if (r)
- r->m_bMessageSessionActive = TRUE;
+ r->m_bMessageSessionActive = true;
- JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
+ JabberCapsBits jcb = GetResourceCapabilites(szClientJid, true);
if (jcb & JABBER_RESOURCE_CAPS_ERROR)
jcb = JABBER_RESOURCE_CAPS_NONE;
@@ -1001,7 +990,7 @@ int __cdecl CJabberProto::SendMsg(MCONTACT hContact, int, const char* pszSrc) // if message sent to groupchat
!mir_wstrcmp(msgType, L"groupchat") ||
// if message delivery check disabled in settings
- !m_options.MsgAck || !getByte(hContact, "MsgAck", TRUE))
+ !m_options.MsgAck || !getByte(hContact, "MsgAck", true))
{
if (!mir_wstrcmp(msgType, L"groupchat"))
XmlAddAttr(m, L"to", szClientJid);
@@ -1239,7 +1228,7 @@ int __cdecl CJabberProto::UserIsTyping(MCONTACT hContact, int type) if (item == NULL)
return 0;
- JabberCapsBits jcb = GetResourceCapabilites(szClientJid, TRUE);
+ JabberCapsBits jcb = GetResourceCapabilites(szClientJid, true);
if (jcb & JABBER_RESOURCE_CAPS_ERROR)
jcb = JABBER_RESOURCE_CAPS_NONE;
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index bbe3cb9165..aa2218411d 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -312,7 +312,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface //---- jabber_caps.cpp ---------------------------------------------------------------
JabberCapsBits GetTotalJidCapabilites(const wchar_t *jid);
- JabberCapsBits GetResourceCapabilites(const wchar_t *jid, BOOL appendBestResource);
+ JabberCapsBits GetResourceCapabilites(const wchar_t *jid, bool appendBestResource);
//---- jabber_captcha.cpp ------------------------------------------------------------
@@ -386,7 +386,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface int SetupServiceDiscoveryDlg(wchar_t* jid);
void OnIqResultCapsDiscoInfo(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultCapsDiscoInfoSI(HXML iqNode, CJabberIqInfo *pInfo);
void RegisterAgent(HWND hwndDlg, wchar_t* jid);
@@ -485,7 +484,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface void OnIqResultSetRegister(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultSetSearch(HXML iqNode, CJabberIqInfo *pInfo);
void OnIqResultSetVcard(HXML iqNode, CJabberIqInfo *pInfo);
- void OnIqResultVersion(HXML node, CJabberIqInfo *pInfo);
void OnProcessLoginRq(ThreadData *info, DWORD rq);
void OnLoggedIn(void);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index ead661cfa5..f8472cd9e4 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1260,7 +1260,7 @@ void CJabberProto::OnProcessMessage(HXML node, ThreadData *info) else if (!mir_wstrcmp(ptszXmlns, JABBER_FEAT_MESSAGE_EVENTS)) {
// set events support only if we discovered caps and if events not already set
- JabberCapsBits jcbCaps = GetResourceCapabilites(from, TRUE);
+ JabberCapsBits jcbCaps = GetResourceCapabilites(from, true);
if (jcbCaps & JABBER_RESOURCE_CAPS_ERROR)
jcbCaps = JABBER_RESOURCE_CAPS_NONE;
// FIXME: disabled due to expired XEP-0022 and problems with bombus delivery checks
@@ -1439,25 +1439,41 @@ void CJabberProto::OnProcessPresenceCapabilites(HXML node) if (r == NULL)
return;
- // check XEP-0115 support, an old style:
- HXML n;
- if ((n = XmlGetChildByTag(node, "c", "xmlns", JABBER_FEAT_ENTITY_CAPS)) != nullptr || (n = XmlGetChild(node, "c")) != nullptr) {
- const wchar_t *hash = XmlGetAttrValue(n, L"hash");
- const wchar_t *szNode = XmlGetAttrValue(n, L"node");
- const wchar_t *szVer = XmlGetAttrValue(n, L"ver");
- const wchar_t *szExt = XmlGetAttrValue(n, L"ext");
- if (szNode && szVer && hash == nullptr) {
- r->m_tszCapsNode = mir_wstrdup(szNode);
- r->m_tszCapsVer = mir_wstrdup(szVer);
- r->m_tszCapsExt = mir_wstrdup(szExt);
- MCONTACT hContact = HContactFromJID(from);
- if (hContact)
- UpdateMirVer(hContact, r);
+ // XEP-0115 support
+ if (r->m_pCaps == nullptr) {
+ HXML n = XmlGetChildByTag(node, "c", "xmlns", JABBER_FEAT_ENTITY_CAPS);
+ if (n != nullptr) {
+ const wchar_t *szNode = XmlGetAttrValue(n, L"node");
+ const wchar_t *szVer = XmlGetAttrValue(n, L"ver");
+ const wchar_t *szExt = XmlGetAttrValue(n, L"ext");
+ if (szNode && szVer) {
+ const wchar_t *szHash = XmlGetAttrValue(n, L"hash");
+ if (szHash == nullptr) { // old version
+ ptrA szVerUtf(mir_utf8encodeW(szVer));
+ BYTE hashOut[MIR_SHA1_HASH_SIZE];
+ mir_sha1_hash((BYTE*)szVerUtf.get(), mir_strlen(szVerUtf), hashOut);
+ wchar_t szHashOut[MIR_SHA1_HASH_SIZE * 2 + 1];
+ bin2hexW(hashOut, _countof(hashOut), szHashOut);
+ r->m_pCaps = m_clientCapsManager.GetPartialCaps(szNode, szHashOut);
+ if (r->m_pCaps == nullptr)
+ r->m_pCaps = m_clientCapsManager.SetClientCaps(szNode, szHash, szVer, JABBER_RESOURCE_CAPS_NONE);
+
+ MCONTACT hContact = HContactFromJID(from);
+ if (hContact)
+ UpdateMirVer(hContact, r);
+ }
+ else {
+ r->m_pCaps = m_clientCapsManager.GetPartialCaps(szNode, szVer);
+ if (r->m_pCaps == nullptr) {
+ r->m_pCaps = m_clientCapsManager.SetClientCaps(szNode, szVer, L"", JABBER_RESOURCE_CAPS_UNINIT);
+ GetResourceCapabilites(from, false);
+ }
+ }
+
+ r->m_tszCapsExt = mir_wstrdup(szExt);
+ }
}
}
-
- // update user's caps
- // JabberCapsBits jcbCaps = GetResourceCapabilites(from, TRUE);
}
void CJabberProto::UpdateJidDbSettings(const wchar_t *jid)
@@ -1744,37 +1760,6 @@ void CJabberProto::OnProcessPresence(HXML node, ThreadData *info) }
}
-void CJabberProto::OnIqResultVersion(HXML /*node*/, CJabberIqInfo *pInfo)
-{
- pResourceStatus r(ResourceInfoFromJID(pInfo->GetFrom()));
- if (r == NULL)
- return;
-
- r->m_dwVersionRequestTime = -1;
-
- r->m_tszSoftware = NULL;
- r->m_tszSoftwareVersion = NULL;
- r->m_tszOs = NULL;
-
- HXML queryNode = pInfo->GetChildNode();
-
- if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT && queryNode) {
- HXML n;
- if ((n = XmlGetChild(queryNode, "name")) != NULL && XmlGetText(n))
- r->m_tszSoftware = mir_wstrdup(XmlGetText(n));
- if ((n = XmlGetChild(queryNode, "version")) != NULL && XmlGetText(n))
- r->m_tszSoftwareVersion = mir_wstrdup(XmlGetText(n));
- if ((n = XmlGetChild(queryNode, "os")) != NULL && XmlGetText(n))
- r->m_tszOs = mir_wstrdup(XmlGetText(n));
- }
-
- GetResourceCapabilites(pInfo->GetFrom(), TRUE);
- if (pInfo->GetHContact())
- UpdateMirVer(pInfo->GetHContact(), r);
-
- JabberUserInfoUpdate(pInfo->GetHContact());
-}
-
BOOL CJabberProto::OnProcessJingle(HXML node)
{
LPCTSTR type;
diff --git a/protocols/JabberG/src/jabber_userinfo.cpp b/protocols/JabberG/src/jabber_userinfo.cpp index 9838842db4..42659c2485 100644 --- a/protocols/JabberG/src/jabber_userinfo.cpp +++ b/protocols/JabberG/src/jabber_userinfo.cpp @@ -168,7 +168,7 @@ void sttCleanupInfo(HWND hwndTree, int stage) } } -static HTREEITEM sttFillInfoLine(HWND hwndTree, HTREEITEM htiRoot, HICON hIcon, wchar_t *title, wchar_t *value, LPARAM id=INFOLINE_BAD_ID, bool expand=false) +static HTREEITEM sttFillInfoLine(HWND hwndTree, HTREEITEM htiRoot, HICON hIcon, const wchar_t *title, const wchar_t *value, LPARAM id = INFOLINE_BAD_ID, bool expand = false) { HTREEITEM hti = sttFindInfoLine(hwndTree, htiRoot, id); @@ -224,30 +224,33 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti sttInfoLineId(resource, INFOLINE_MESSAGE)); // Software - HICON hIcon = NULL; - if ( ServiceExists(MS_FP_GETCLIENTICONT)) { - if (r->m_tszSoftware != NULL) { - mir_snwprintf(buf, L"%s %s", r->m_tszSoftware, r->m_tszSoftwareVersion); - hIcon = Finger_GetClientIcon(buf, 0); + if (CJabberClientPartialCaps *pCaps = r->m_pCaps) { + HICON hIcon = nullptr; + + if (ServiceExists(MS_FP_GETCLIENTICONT)) { + if (pCaps->GetSoft()) { + mir_snwprintf(buf, L"%s %s", pCaps->GetSoft(), pCaps->GetSoftVer()); + hIcon = Finger_GetClientIcon(buf, 0); + } } - } - sttFillInfoLine(hwndTree, htiResource, hIcon, TranslateT("Software"), - r->m_tszSoftware ? r->m_tszSoftware : TranslateT("<not specified>"), - sttInfoLineId(resource, INFOLINE_SOFTWARE)); + sttFillInfoLine(hwndTree, htiResource, hIcon, TranslateT("Software"), + pCaps->GetSoft() ? pCaps->GetSoft() : TranslateT("<not specified>"), + sttInfoLineId(resource, INFOLINE_SOFTWARE)); - if (hIcon) - DestroyIcon(hIcon); + // Version + sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("Version"), + pCaps->GetSoftVer() ? pCaps->GetSoftVer() : TranslateT("<not specified>"), + sttInfoLineId(resource, INFOLINE_VERSION)); - // Version - sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("Version"), - r->m_tszSoftwareVersion ? r->m_tszSoftwareVersion : TranslateT("<not specified>"), - sttInfoLineId(resource, INFOLINE_VERSION)); + // System + sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("System"), + pCaps->GetOs() ? pCaps->GetOs() : TranslateT("<not specified>"), + sttInfoLineId(resource, INFOLINE_SYSTEM)); - // System - sttFillInfoLine(hwndTree, htiResource, NULL, TranslateT("System"), - r->m_tszOs ? r->m_tszOs : TranslateT("<not specified>"), - sttInfoLineId(resource, INFOLINE_SYSTEM)); + if (hIcon) + DestroyIcon(hIcon); + } // Resource priority wchar_t szPriority[128]; @@ -299,16 +302,18 @@ static void sttFillResourceInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM hti // Software info HTREEITEM htiSoftwareInfo = sttFillInfoLine(hwndTree, htiResource, ppro->LoadIconEx("main"), NULL, TranslateT("Software information"), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION)); int nLineId = 0; - if (r->m_tszOs) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system"), r->m_tszOs, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); - if (r->m_tszOsVersion) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system version"), r->m_tszOsVersion, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); - if (r->m_tszSoftware) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Software"), r->m_tszSoftware, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); - if (r->m_tszSoftwareVersion) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Software version"), r->m_tszSoftwareVersion, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); - if (r->m_tszXMirandaCoreVersion) - sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Miranda core version"), r->m_tszXMirandaCoreVersion, sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + if (CJabberClientPartialCaps *pCaps = r->m_pCaps) { + if (pCaps->GetOs()) + sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system"), pCaps->GetOs(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + if (pCaps->GetOsVer()) + sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Operating system version"), pCaps->GetOsVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + if (pCaps->GetSoft()) + sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Software"), pCaps->GetSoft(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + if (pCaps->GetSoftVer()) + sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Software version"), pCaps->GetSoftVer(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + if (pCaps->GetSoftMir()) + sttFillInfoLine(hwndTree, htiSoftwareInfo, NULL, TranslateT("Miranda core version"), pCaps->GetSoftMir(), sttInfoLineId(resource, INFOLINE_SOFTWARE_INFORMATION, nLineId++)); + } } static void sttFillAdvStatusInfo(CJabberProto *ppro, HWND hwndTree, HTREEITEM htiRoot, DWORD dwInfoLine, MCONTACT hContact, wchar_t *szTitle, char *pszSlot) diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index 32f55eb0b1..656958030b 100755 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -551,11 +551,6 @@ wchar_t* CJabberProto::GetClientJID(const wchar_t *jid, wchar_t *dest, size_t de mir_cslock lck(m_csLists);
JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid);
if (LI != NULL) {
- if (LI->arResources.getCount() == 1 && !mir_wstrcmp(LI->arResources[0]->m_tszCapsNode, L"http://talk.google.com/xmpp/bot/caps")) {
- if (p) *p = 0;
- return dest;
- }
-
if (p == NULL) {
pResourceStatus r(LI->getBestResource());
if (r != NULL)
|