From 4539d364466d9d934c8b2fbd1642ffbeba0bc75d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 19 Feb 2019 18:19:11 +0300 Subject: all !!! fixed --- protocols/JabberG/src/jabber_chat.cpp | 1 - protocols/JabberG/src/jabber_console.cpp | 15 +++++------- protocols/JabberG/src/jabber_disco.cpp | 12 +++++----- protocols/JabberG/src/jabber_proto.cpp | 2 -- protocols/JabberG/src/jabber_proto.h | 1 + protocols/JabberG/src/jabber_thread.cpp | 41 +++++++++++++++++++------------- 6 files changed, 37 insertions(+), 35 deletions(-) (limited to 'protocols/JabberG/src') diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index f5343007d9..ac1a145931 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -561,7 +561,6 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam) continue; gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, idx); - //!!!!!!!!!!!!!!!!!! pItem->pszDesc = item->jid; pItem->uType = MENU_POPUPITEM; if (++idx > IDM_LINK9) break; diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp index e0c4d8589a..7a57186c18 100644 --- a/protocols/JabberG/src/jabber_console.cpp +++ b/protocols/JabberG/src/jabber_console.cpp @@ -103,9 +103,9 @@ void CJabberProto::OnConsoleProcessXml(const TiXmlElement *node, DWORD flags) bool CJabberProto::RecursiveCheckFilter(const TiXmlElement *node, DWORD flags) { - // !!!!!!!!!!!!!!!!for (int i = 0; i < node->Attribute); i++) - // !!!!!!!!!!!!!!!! if (JabberStrIStr(XmlGetAttr(node, i), m_filterInfo.pattern)) - // !!!!!!!!!!!!!!!! return true; + for (auto *p = node->FirstAttribute(); p; p = p->Next()) + if (JabberStrIStr(Utf2T(p->Value()), m_filterInfo.pattern)) + return true; for (auto *it : TiXmlEnum(node)) if (RecursiveCheckFilter(it, flags)) @@ -203,20 +203,17 @@ static void sttRtfAppendXml(StringBuf *buf, const TiXmlElement *node, DWORD flag sttAppendBufRaw(buf, node->Name()); sttAppendBufRaw(buf, RTF_ENDTAGNAME); - // !!!!!!!!!!!!!!!! - /*for (int i = 0; i < XmlGetAttrCount(node); i++) { - wchar_t *attr = (wchar_t*)xmlGetAttrName(node, i); + for (auto *p = node->FirstAttribute(); p; p = p->Next()) { sttAppendBufRaw(buf, " "); sttAppendBufRaw(buf, RTF_BEGINATTRNAME); - sttAppendBufW(buf, attr); + sttAppendBufW(buf, Utf2T(p->Name())); sttAppendBufRaw(buf, RTF_ENDATTRNAME); sttAppendBufRaw(buf, "=\""); sttAppendBufRaw(buf, RTF_BEGINATTRVAL); - sttAppendBufT(buf, (wchar_t*)XmlGetAttr(node, i)); + sttAppendBufT(buf, Utf2T(p->Value())); sttAppendBufRaw(buf, "\""); sttAppendBufRaw(buf, RTF_ENDATTRVAL); } - */ if (!node->NoChildren() || node->GetText()) { sttAppendBufRaw(buf, ">"); diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp index a82b328c75..5edc36a481 100644 --- a/protocols/JabberG/src/jabber_disco.cpp +++ b/protocols/JabberG/src/jabber_disco.cpp @@ -1215,7 +1215,7 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM case SD_ACT_REFRESHCHILDREN: { - TiXmlDocument packet; + XmlNode packet(nullptr); { mir_cslock lck(m_SDManager.cs()); for (int iChild = TreeList_GetChildrenCount(hItem); iChild--;) { @@ -1224,14 +1224,14 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM if (n) { TreeList_ResetItem(GetDlgItem(m_pDlgServiceDiscovery->GetHwnd(), IDC_TREE_DISCO), hNode); n->ResetInfo(); - SendBothRequests(n, packet.ToElement()); + SendBothRequests(n, packet); TreeList_MakeFakeParent(hNode, FALSE); } - //!!!!!!!!!!!!!!!!!! if (packet > 50) { - m_ThreadInfo->send(packet.ToElement()); - packet.Clear(); - ///} + if (XmlGetChildCount(packet) > 50) { + m_ThreadInfo->send(packet); + packet.Clear(); + } } } diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 7abe66e602..f9c214d730 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -131,8 +131,6 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : m_bUseOMEMO(this, "UseOMEMO", false), m_bEnableStreamMgmt(this, "UseStreamMgmt", false) { - m_szXmlStreamToBeInitialized = nullptr; - debugLogA("Setting protocol/module name to '%s'", m_szModuleName); // Protocol services and events... diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index cce4482df5..d21b7a0078 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -216,6 +216,7 @@ struct CJabberProto : public PROTO, public IJabberInterface bool m_bShutdown; bool m_bSendKeepAlive; bool m_bPepSupported; + bool m_bStreamSent; HWND m_hwndAgentRegInput; HWND m_hwndRegProgress; diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index c274eb8003..fc38cb09e9 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -190,20 +190,16 @@ void ThreadData::xmpp_client_query(void) void CJabberProto::xmlStreamInitialize(char *szWhich) { debugLogA("Stream will be initialized %s", szWhich); - if (m_szXmlStreamToBeInitialized) - free(m_szXmlStreamToBeInitialized); - m_szXmlStreamToBeInitialized = _strdup(szWhich); + replaceStr(m_szXmlStreamToBeInitialized, szWhich); } void CJabberProto::xmlStreamInitializeNow(ThreadData *info) { debugLogA("Stream is initializing %s", m_szXmlStreamToBeInitialized ? m_szXmlStreamToBeInitialized : "after connect"); - if (m_szXmlStreamToBeInitialized) { - free(m_szXmlStreamToBeInitialized); - m_szXmlStreamToBeInitialized = nullptr; - } + replaceStr(m_szXmlStreamToBeInitialized, 0); + m_bStreamSent = true; XmlNode n("stream:stream"); n << XATTR("xmlns", "jabber:client") << XATTR("to", info->conn.server) << XATTR("xmlns:stream", "http://etherx.jabber.org/streams"); n.InsertFirstChild(n.NewDeclaration("xml version=\"1.0\" encoding=\"UTF-8\"")); @@ -451,24 +447,35 @@ recvRest: int bytesParsed = 0; TiXmlDocument root; - if (0 == root.Parse(info.buffer)) { - for (auto *n : TiXmlEnum(&root)) - OnProcessProtocol(n, &info); - bytesParsed = root.BytesParsed(); + if (m_bStreamSent) { + m_bStreamSent = false; + char *p = strstr(info.buffer, "'); + if (q) { + CMStringA tmp(info.buffer, int(q - info.buffer)+1); + tmp.Append(""); + + if (0 == root.Parse(tmp)) { + for (auto *n : TiXmlEnum(&root)) + OnProcessProtocol(n, &info); + bytesParsed = root.BytesParsed() - 16; + debugLogA("bytesParsed = %d", bytesParsed); + } + } + } } - else if (root.ErrorID() == 14) { - root.Clear(); - strcpy(&info.buffer[datalen], ""); - datalen = (int)strlen(info.buffer); + + if (bytesParsed == 0) { if (0 == root.Parse(info.buffer)) { for (auto *n : TiXmlEnum(&root)) OnProcessProtocol(n, &info); bytesParsed = root.BytesParsed(); + debugLogA("bytesParsed = %d", bytesParsed); } + else debugLogA("parsing error %d: %s", root.ErrorID(), root.ErrorStr()); } - debugLogA("bytesParsed = %d", bytesParsed); - if (bytesParsed > 0) { if (bytesParsed < datalen) memmove(info.buffer, info.buffer + bytesParsed, datalen - bytesParsed); -- cgit v1.2.3