summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-08-14 17:57:18 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-08-14 17:57:18 +0300
commit2c33d3a74a28953786f9fd5b76a76c1184751f21 (patch)
treec1f341679a62b339e016ac0faac1749fc07534f7 /protocols
parentcc9adee406ad0434e470dfc11ed3896c6be32073 (diff)
Jabber: version info to be cached into a profile
Diffstat (limited to 'protocols')
-rwxr-xr-xprotocols/JabberG/src/jabber_caps.cpp34
-rwxr-xr-xprotocols/JabberG/src/jabber_caps.h3
-rwxr-xr-xprotocols/JabberG/src/jabber_thread.cpp17
-rw-r--r--protocols/JabberG/src/stdafx.h1
4 files changed, 41 insertions, 14 deletions
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp
index bebc647c12..bc90345469 100755
--- a/protocols/JabberG/src/jabber_caps.cpp
+++ b/protocols/JabberG/src/jabber_caps.cpp
@@ -137,10 +137,27 @@ void CJabberProto::OnIqResultCapsDiscoInfo(HXML, CJabberIqInfo *pInfo)
}
HXML xform;
- for (int i = 1; (xform = XmlGetNthChild(query, L"x", i)) != NULL; i++) {
+ for (int i = 1; (xform = XmlGetNthChild(query, L"x", i)) != nullptr; i++) {
wchar_t *szFormTypeValue = XPath(xform, L"field[@var='FORM_TYPE']/value");
- if (!mir_wstrcmp(szFormTypeValue, L"urn:xmpp:dataforms:softwareinfo"))
- pCaps->Parse(xform);
+ if (!mir_wstrcmp(szFormTypeValue, L"urn:xmpp:dataforms:softwareinfo")) {
+ pCaps->m_szOs = mir_wstrdup(XPath(xform, L"field[@var='os']/value"));
+ pCaps->m_szOsVer = mir_wstrdup(XPath(xform, L"field[@var='os_version']/value"));
+ pCaps->m_szSoft = mir_wstrdup(XPath(xform, L"field[@var='software']/value"));
+ pCaps->m_szSoftVer = mir_wstrdup(XPath(xform, L"field[@var='software_version']/value"));
+ pCaps->m_szSoftMir = mir_wstrdup(XPath(xform, L"field[@var='x-miranda-core-version']/value"));
+
+ JSONNode root;
+ root.push_back(JSONNode("o", _T2A(pCaps->m_szOs)));
+ root.push_back(JSONNode("ov", _T2A(pCaps->m_szOsVer)));
+ root.push_back(JSONNode("s", _T2A(pCaps->m_szSoft)));
+ root.push_back(JSONNode("sv", _T2A(pCaps->m_szSoftVer)));
+ root.push_back(JSONNode("sm", _T2A(pCaps->m_szSoftMir)));
+ root.push_back(JSONNode("ñ", CMStringA(FORMAT, "%lld", jcbCaps)));
+
+ CMStringA szName(FORMAT, "%S#%S", pCaps->GetNode(), pCaps->GetHash());
+ json_string szValue = root.write();
+ db_set_s(0, "JabberCaps", szName, szValue.c_str());
+ }
}
pCaps->SetCaps(jcbCaps, pInfo->GetIqId());
@@ -209,7 +226,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const wchar_t *jid, bool app
// XEP-0115 mode
if (r->m_pCaps) {
CJabberClientPartialCaps *pCaps = r->m_pCaps;
- JabberCapsBits jcbCaps = 0, jcbExtCaps = 0;
+ JabberCapsBits jcbCaps = 0;
bool bRequestSent = false;
JabberCapsBits jcbMainCaps = pCaps->GetCaps();
@@ -287,15 +304,6 @@ CJabberClientPartialCaps* CJabberClientPartialCaps::SetNext(CJabberClientPartial
return pRetVal;
}
-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)
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h
index 70f1ff188c..363fb27614 100755
--- a/protocols/JabberG/src/jabber_caps.h
+++ b/protocols/JabberG/src/jabber_caps.h
@@ -209,6 +209,8 @@ typedef unsigned __int64 JabberCapsBits;
class CJabberClientPartialCaps
{
+ friend struct CJabberProto;
+
ptrW m_szHash, m_szOs, m_szOsVer, m_szSoft, m_szSoftVer, m_szSoftMir;
JabberCapsBits m_jcbCaps;
int m_nIqId;
@@ -226,7 +228,6 @@ public:
{ return m_pNext;
}
- void Parse(HXML);
void SetCaps(JabberCapsBits jcbCaps, int nIqId = -1);
JabberCapsBits GetCaps();
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 49f6f8a8e8..eef8392df4 100755
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -1465,6 +1465,23 @@ void CJabberProto::OnProcessPresenceCapabilites(HXML node)
else {
r->m_pCaps = m_clientCapsManager.GetPartialCaps(szNode, szVer);
if (r->m_pCaps == nullptr) {
+ CMStringA szName(FORMAT, "%S#%S", szNode, szVer);
+ ptrA szValue(db_get_sa(0, "JabberCaps", szName));
+ if (szValue != 0) {
+ JSONNode root = JSONNode::parse(szValue);
+ if (root) {
+ CMStringW wszCaps = root["c"].as_mstring();
+ r->m_pCaps = m_clientCapsManager.SetClientCaps(szNode, szVer, nullptr, _wtoi64(wszCaps));
+ r->m_pCaps->m_szOs = mir_wstrdup(root["o"].as_mstring());
+ r->m_pCaps->m_szOsVer = mir_wstrdup(root["ov"].as_mstring());
+ r->m_pCaps->m_szSoft = mir_wstrdup(root["s"].as_mstring());
+ r->m_pCaps->m_szSoftVer = mir_wstrdup(root["sv"].as_mstring());
+ r->m_pCaps->m_szSoftMir = mir_wstrdup(root["sm"].as_mstring());
+ }
+ }
+ }
+
+ if (r->m_pCaps == nullptr) {
r->m_pCaps = m_clientCapsManager.SetClientCaps(szNode, szVer, L"", JABBER_RESOURCE_CAPS_UNINIT);
GetResourceCapabilites(from, false);
}
diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h
index c5b440f7e2..5611ca6dcf 100644
--- a/protocols/JabberG/src/stdafx.h
+++ b/protocols/JabberG/src/stdafx.h
@@ -77,6 +77,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <m_protosvc.h>
#include <m_protoint.h>
#include <m_skin.h>
+#include <m_json.h>
#include <m_string.h>
#include <m_timezones.h>
#include <m_toptoolbar.h>