diff options
author | George Hazan <ghazan@miranda.im> | 2022-09-14 01:25:24 -0700 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-09-14 01:25:24 -0700 |
commit | f37ebb5b91504b621a048c66c3deedf0a6baf4a6 (patch) | |
tree | 86a0849c171b94544598c89c7e0f32f905df038d /protocols/JabberG | |
parent | 2b2cb6266a26ef9bbd1e2910ea6f4f4953a9841a (diff) |
Jabber: warning fix + code cleaning
Diffstat (limited to 'protocols/JabberG')
-rw-r--r-- | protocols/JabberG/src/jabber_strm_mgmt.cpp | 39 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_strm_mgmt.h | 11 |
2 files changed, 27 insertions, 23 deletions
diff --git a/protocols/JabberG/src/jabber_strm_mgmt.cpp b/protocols/JabberG/src/jabber_strm_mgmt.cpp index bc39f3c0bd..cbba6b5daa 100644 --- a/protocols/JabberG/src/jabber_strm_mgmt.cpp +++ b/protocols/JabberG/src/jabber_strm_mgmt.cpp @@ -23,14 +23,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
#include "jabber_strm_mgmt.h"
+#define CACHE_SIZE 10
+
strm_mgmt::strm_mgmt(CJabberProto *_proto) :
proto(_proto)
{
+ ResetState();
}
void strm_mgmt::OnProcessEnabled(const TiXmlElement *node, ThreadData * /*info*/)
{
m_bEnabled = true;
+ m_tConnLostTime = 0;
+
auto *val = XmlGetAttr(node, "resume");
if (val) {
if (mir_strcmp(val, "true") || mir_strcmp(val, "1")) {
@@ -61,9 +66,10 @@ void strm_mgmt::OnProcessResumed(const TiXmlElement *node, ThreadData * /*info*/ var = XmlGetAttr(node, "h");
if (!var)
return;
- m_bSessionResumed = true;
- m_bEnabled = true;
+
+ m_bSessionResumed = m_bEnabled = true;
m_bPendingEnable = false;
+ m_tConnLostTime = 0;
m_nSrvHCount = atoi(var);
int size = m_nLocalSCount - m_nSrvHCount;
@@ -180,11 +186,8 @@ void strm_mgmt::CheckStreamFeatures(const TiXmlElement *node) void strm_mgmt::CheckState()
{
- if (m_bEnabled)
- return;
- if (!m_bPendingEnable)
- return;
- EnableStrmMgmt();
+ if (!m_bEnabled && m_bPendingEnable)
+ EnableStrmMgmt();
}
void strm_mgmt::HandleOutgoingNode(TiXmlElement *node)
@@ -198,21 +201,21 @@ void strm_mgmt::HandleOutgoingNode(TiXmlElement *node) m_nLocalSCount++;
NodeCache.push_back(pNodeCopy);
- if ((m_nLocalSCount - m_nSrvHCount) >= m_nCacheSize
- || m_nLocalSCount % 3 == 0)
+ if ((m_nLocalSCount - m_nSrvHCount) >= CACHE_SIZE || m_nLocalSCount % 3 == 0)
RequestAck();
}
void strm_mgmt::ResetState()
{
- //reset state of stream management
- m_bEnabled = false;
- m_bPendingEnable = false;
+ // reset state of stream management
+ m_bEnabled = m_bPendingEnable = false;
m_nResumeMaxSeconds = 0;
m_tConnLostTime = 0;
- //reset stream management h counters
+
+ // reset stream management h counters
m_nLocalHCount = m_nLocalSCount = m_nSrvHCount = 0;
- //clear resume id
+
+ // clear resume id
m_sResumeId.clear();
}
@@ -242,15 +245,15 @@ void strm_mgmt::EnableStrmMgmt() {
if (m_bEnabled)
return;
+
if (m_sResumeId.empty()) {
XmlNode enable_sm("enable");
XmlAddAttr(enable_sm, "xmlns", "urn:xmpp:sm:3");
- XmlAddAttr(enable_sm, "resume", "true"); //enable resumption (most useful part of this xep)
+ XmlAddAttr(enable_sm, "resume", "true"); // enable resumption (most useful part of this xep)
proto->m_ThreadInfo->send(enable_sm);
- m_nLocalSCount = 1; //TODO: this MUST be 0, i have bug somewhere, feel free to fix it.
+ m_nLocalSCount = 1; // TODO: this MUST be 0, i have bug somewhere, feel free to fix it.
}
- else //resume session
- {
+ else { // resume session
XmlNode enable_sm("resume");
enable_sm << XATTR("xmlns", "urn:xmpp:sm:3") << XATTRI("h", m_nLocalHCount) << XATTR("previd", m_sResumeId.c_str());
proto->m_ThreadInfo->send(enable_sm);
diff --git a/protocols/JabberG/src/jabber_strm_mgmt.h b/protocols/JabberG/src/jabber_strm_mgmt.h index fae80df6ba..412127d1d2 100644 --- a/protocols/JabberG/src/jabber_strm_mgmt.h +++ b/protocols/JabberG/src/jabber_strm_mgmt.h @@ -38,13 +38,14 @@ class strm_mgmt CJabberProto *proto;
TiXmlDocument xmlStorage;
- uint32_t m_nSrvHCount, m_nLocalHCount, m_nLocalSCount, m_nResumeMaxSeconds = 0;
- const uint32_t m_nCacheSize = 10;
- bool m_bEnabled = false;
- bool m_bPendingEnable = false;
+
+ bool m_bEnabled;
+ bool m_bPendingEnable;
bool m_bResumeSupported = false;
bool m_bSessionResumed = false;
- time_t m_tConnLostTime = 0;
+
+ int m_nSrvHCount, m_nLocalHCount, m_nLocalSCount, m_nResumeMaxSeconds;
+ time_t m_tConnLostTime;
std::string m_sResumeId;
std::list<TiXmlElement*> NodeCache;
|