diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2018-03-25 21:11:42 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2018-03-26 06:41:10 +0300 |
commit | b704521b152acf8f449182e28113394edca404fe (patch) | |
tree | 108eb0b3ef3c3a1a17c4c7b3c0dc3a74a53a9d79 | |
parent | b2c47fe47b18d21b90d9c536e70bf45ef9d33e3c (diff) |
protocols: jabber: work on xep-0198
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.cpp | 8 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.h | 7 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_thread.cpp | 34 |
3 files changed, 39 insertions, 10 deletions
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index ceb5fbf44f..f4de9de9d0 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -71,6 +71,8 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : m_hPrivacyMenuItems(10),
m_lstJabberFeatCapPairsDynamic(2),
m_uEnabledFeatCapsDynamic(0),
+ m_bStrmMgmtPendingEnable(false),
+ m_bStrmMgmtEnabled(false),
m_bBsDirect(this, "BsDirect", TRUE),
m_bAllowVersionRequests(this, "m_bAllowVersionRequests", TRUE),
@@ -1341,3 +1343,9 @@ int __cdecl CJabberProto::OnEvent(PROTOEVENTTYPE eventType, WPARAM wParam, LPARA }
return 1;
}
+
+
+void CJabberProto::m_nStrmMgmtLocalSCount_incr()
+{
+ m_nStrmMgmtLocalSCount++;
+}
\ No newline at end of file diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index f11c41656e..b768f75df9 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -284,6 +284,10 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface int m_nIqIdRegGetReg;
int m_nIqIdRegSetReg;
+ //xep-0198 handled nodes count
+ uint32_t m_nStrmMgmtSrvHCount, m_nStrmMgmtLocalHCount, m_nStrmMgmtLocalSCount;
+ bool m_bStrmMgmtPendingEnable, m_bStrmMgmtEnabled;
+
int m_nSDBrowseMode;
DWORD m_dwSDLastRefresh;
DWORD m_dwSDLastAutoDisco;
@@ -800,6 +804,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface bool ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info);
void EnableCarbons(bool bEnable);
+ void EnableStrmMgmt();
//---- jabber_util.c -----------------------------------------------------------------
pResourceStatus ResourceInfoFromJID(const wchar_t *jid);
@@ -925,6 +930,8 @@ public: HNETLIBUSER STDMETHODCALLTYPE GetHandle(); // Returns connection handle
+ void m_nStrmMgmtLocalSCount_incr();
+
private:
JabberFeatCapPairDynamic *FindFeature(const wchar_t *szFeature);
};
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 1b46d0e63f..d95fc2f91b 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -663,6 +663,8 @@ void CJabberProto::PerformAuthentication(ThreadData *info) info->send(XmlNode(L"auth", _A2T(request)) << XATTR(L"xmlns", L"urn:ietf:params:xml:ns:xmpp-sasl")
<< XATTR(L"mechanism", _A2T(auth->getName())));
mir_free(request);
+ if (m_bEnableStreamMgmt && m_bStrmMgmtPendingEnable)
+ EnableStrmMgmt();
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -741,17 +743,9 @@ void CJabberProto::OnProcessFeatures(HXML node, ThreadData *info) if (!mir_wstrcmp(XmlGetAttrValue(n, L"xmlns"), L"urn:xmpp:sm:3")) //we work only with version 3 or higher of sm
{
if (!(info->auth))
- {
- //TODO: queue sm after successfully auth
- }
+ m_bStrmMgmtPendingEnable = true;
else
- {
- XmlNode enable_sm(L"enable");
- XmlAddAttr(enable_sm, L"xmlns", L"urn:xmpp:sm:3");
- XmlAddAttr(enable_sm, L"resume", L"true"); //enable resumption (most useful part of this xep)
- info->send(enable_sm);
- //TODO: reset counters ?
- }
+ EnableStrmMgmt();
}
}
}
@@ -803,6 +797,7 @@ void CJabberProto::OnProcessEnabled(HXML node, ThreadData * /*info*/) {
if (m_bEnableStreamMgmt && !mir_wstrcmp(XmlGetAttrValue(node, L"xmlns"), L"urn:xmpp:sm:3"))
{
+ m_bStrmMgmtEnabled = true;
//TODO: handle 'id', 'resume' attrs
}
}
@@ -899,6 +894,8 @@ void CJabberProto::OnProcessProtocol(HXML node, ThreadData *info) {
OnConsoleProcessXml(node, JCPF_IN);
+ if (m_bEnableStreamMgmt && m_bStrmMgmtEnabled)
+ m_nStrmMgmtLocalHCount++;
if (!mir_wstrcmp(XmlGetName(node), L"proceed"))
OnProcessProceed(node, info);
else if (!mir_wstrcmp(XmlGetName(node), L"compressed"))
@@ -2053,6 +2050,17 @@ void CJabberProto::EnableCarbons(bool bEnable) << XCHILDNS((bEnable) ? L"enable" : L"disable", JABBER_FEAT_CARBONS));
}
+void CJabberProto::EnableStrmMgmt()
+{
+ XmlNode enable_sm(L"enable");
+ XmlAddAttr(enable_sm, L"xmlns", L"urn:xmpp:sm:3");
+ XmlAddAttr(enable_sm, L"resume", L"true"); //enable resumption (most useful part of this xep)
+ m_ThreadInfo->send(enable_sm);
+ m_nStrmMgmtLocalHCount = 0;
+ m_nStrmMgmtSrvHCount = 0; //?
+ m_nStrmMgmtLocalSCount = 0;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// ThreadData constructor & destructor
@@ -2136,6 +2144,10 @@ int ThreadData::send(char* buf, int bufsize) result = sendws(buf, bufsize, MSG_DUMPASTEXT);
ReleaseMutex(iomutex);
+
+ if (proto->m_bEnableStreamMgmt && proto->m_bStrmMgmtEnabled)
+ proto->m_nStrmMgmtLocalSCount_incr();
+
return result;
}
@@ -2172,5 +2184,7 @@ int ThreadData::send(HXML node) int result = send(utfStr, (int)mir_strlen(utfStr));
xmlFree(str);
+ if (proto->m_bEnableStreamMgmt && proto->m_bStrmMgmtEnabled)
+ proto->m_nStrmMgmtLocalSCount_incr();
return result;
}
|