summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/JabberG/src/jabber.h2
-rw-r--r--protocols/JabberG/src/jabber_caps.cpp34
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp12
-rw-r--r--protocols/JabberG/src/jabber_util.cpp7
4 files changed, 28 insertions, 27 deletions
diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h
index 9391a3808f..4d72915a4a 100644
--- a/protocols/JabberG/src/jabber.h
+++ b/protocols/JabberG/src/jabber.h
@@ -756,7 +756,7 @@ void JabberCopyText(HWND hwnd, TCHAR *text);
void JabberBitmapPremultiplyChannels(HBITMAP hBitmap);
CJabberProto *JabberChooseInstance(bool bIsLink=false);
-void JabberReadXep203delay(HXML node, time_t &msgTime);
+bool JabberReadXep203delay(HXML node, time_t &msgTime);
//---- jabber_xml.cpp -------------------------------------------------------------------
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp
index 55911fd311..5b24a7c184 100644
--- a/protocols/JabberG/src/jabber_caps.cpp
+++ b/protocols/JabberG/src/jabber_caps.cpp
@@ -395,7 +395,7 @@ JabberCapsBits CJabberProto::GetResourceCapabilites(const TCHAR *jid, BOOL appen
}
/////////////////////////////////////////////////////////////////////////////////////////
-// CJabberClientPartialCaps class members
+// CJabberClientPartialCaps class
CJabberClientPartialCaps::CJabberClientPartialCaps(const TCHAR *szVer)
{
@@ -467,6 +467,9 @@ CJabberClientPartialCaps* CJabberClientCaps::FindById(int nIqId)
return pCaps;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// CJabberClientCaps class
+
CJabberClientCaps::CJabberClientCaps(const TCHAR *szNode)
{
m_szNode = mir_tstrdup(szNode);
@@ -489,14 +492,14 @@ CJabberClientCaps* CJabberClientCaps::SetNext(CJabberClientCaps *pClient)
return pRetVal;
}
-JabberCapsBits CJabberClientCaps::GetPartialCaps(TCHAR *szVer) {
+JabberCapsBits CJabberClientCaps::GetPartialCaps(TCHAR *szVer)
+{
CJabberClientPartialCaps *pCaps = FindByVersion(szVer);
- if ( !pCaps)
- return JABBER_RESOURCE_CAPS_UNINIT;
- return pCaps->GetCaps();
+ return (pCaps) ? pCaps->GetCaps() : JABBER_RESOURCE_CAPS_UNINIT;
}
-BOOL CJabberClientCaps::SetPartialCaps(const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId /*= -1*/) {
+BOOL CJabberClientCaps::SetPartialCaps(const TCHAR *szVer, JabberCapsBits jcbCaps, int nIqId /*= -1*/)
+{
CJabberClientPartialCaps *pCaps = FindByVersion(szVer);
if ( !pCaps) {
pCaps = new CJabberClientPartialCaps(szVer);
@@ -505,26 +508,24 @@ BOOL CJabberClientCaps::SetPartialCaps(const TCHAR *szVer, JabberCapsBits jcbCap
pCaps->SetNext(m_pCaps);
m_pCaps = pCaps;
}
- if ( !(jcbCaps & JABBER_RESOURCE_CAPS_ERROR) && m_szNode && szVer) {
- if ( !_tcscmp(m_szNode, _T("http://miranda-im.org/caps")) && !_tcscmp(szVer, _T("0.7.0.13")))
- jcbCaps = jcbCaps & (~JABBER_CAPS_MESSAGE_RECEIPTS);
- }
+
pCaps->SetCaps(jcbCaps, nIqId);
return TRUE;
}
-BOOL CJabberClientCaps::SetPartialCaps(int nIqId, JabberCapsBits jcbCaps) {
+BOOL CJabberClientCaps::SetPartialCaps(int nIqId, JabberCapsBits jcbCaps)
+{
CJabberClientPartialCaps *pCaps = FindById(nIqId);
if ( !pCaps)
return FALSE;
- if ( !(jcbCaps & JABBER_RESOURCE_CAPS_ERROR) && m_szNode && pCaps->GetVersion()) {
- if ( !_tcscmp(m_szNode, _T("http://miranda-im.org/caps")) && !_tcscmp(pCaps->GetVersion(), _T("0.7.0.13")))
- jcbCaps = jcbCaps & (~JABBER_CAPS_MESSAGE_RECEIPTS);
- }
+
pCaps->SetCaps(jcbCaps, -1);
return TRUE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// CJabberClientCapsManager class
+
CJabberClientCapsManager::CJabberClientCapsManager(CJabberProto* proto)
{
ppro = proto;
@@ -553,7 +554,8 @@ CJabberClientCaps * CJabberClientCapsManager::FindClient(const TCHAR *szNode)
return pClient;
}
-void CJabberClientCapsManager::AddDefaultCaps() {
+void CJabberClientCapsManager::AddDefaultCaps()
+{
SetClientCaps(_T(JABBER_CAPS_MIRANDA_NODE), szCoreVersion, JABBER_CAPS_MIRANDA_ALL);
for (int i = 0; g_JabberFeatCapPairsExt[i].szFeature; i++)
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index c6b2481a1b..1ecf1db98b 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -1236,13 +1236,11 @@ void CJabberProto::GroupchatProcessMessage(HXML node)
GcLogCreate(item);
time_t msgTime = 0;
- for (int i = 1; (xNode = xmlGetNthChild(node, _T("x"), i)) != NULL; i++)
- if ((p = xmlGetAttrValue(xNode, _T("xmlns"))) != NULL)
- if (!_tcscmp(p, _T("jabber:x:delay")) && !msgTime)
- if ((p = xmlGetAttrValue(xNode, _T("stamp"))) != NULL)
- msgTime = JabberIsoToUnixTime(p);
- if (!msgTime)
- JabberReadXep203delay(xNode, msgTime);
+ if ( !JabberReadXep203delay(node, msgTime)) {
+ HXML xDelay = xmlGetChildByTag(node, "x", "xmlns", _T("jabber:x:delay"));
+ if (xDelay && (p = xmlGetAttrValue(xDelay, _T("stamp"))) != NULL)
+ msgTime = JabberIsoToUnixTime(p);
+ }
time_t now = time(NULL);
if (!msgTime || msgTime > now)
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 795c237033..a80be6ce88 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -1553,15 +1553,15 @@ BOOL CJabberProto::EnterString(TCHAR *result, size_t resultLen, TCHAR *caption,
}
// XEP-0203 delay support
-void JabberReadXep203delay(HXML node, time_t &msgTime)
+bool JabberReadXep203delay(HXML node, time_t &msgTime)
{
HXML n = xmlGetChildByTag(node, "delay", "xmlns", _T("urn:xmpp:delay"));
if (n == NULL)
- return;
+ return false;
const TCHAR *ptszTimeStamp = xmlGetAttrValue(n, _T("stamp"));
if (ptszTimeStamp == NULL)
- return;
+ return false;
// skip '-' chars
TCHAR* szStamp = NEWTSTR_ALLOCA(ptszTimeStamp);
@@ -1574,6 +1574,7 @@ void JabberReadXep203delay(HXML node, time_t &msgTime)
break;
};
msgTime = JabberIsoToUnixTime(szStamp);
+ return msgTime != 0;
}
////////////////////////////////////////////////////////////////////////