From 3d155d30b429a0525c6cc5860c1a04980450f687 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 15 Mar 2021 22:03:48 +0300 Subject: Jabber: minor OMEMO code optimization --- protocols/JabberG/src/jabber_omemo.cpp | 10 +++------- protocols/JabberG/src/jabber_proto.h | 2 +- protocols/JabberG/src/jabber_thread.cpp | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) (limited to 'protocols/JabberG/src') diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index 6fae663ef3..43f4e27ab2 100755 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -1710,16 +1710,12 @@ bool CJabberProto::OmemoHandleMessage(const TiXmlElement *node, const char *jid, return true; } -void CJabberProto::OmemoHandleDeviceList(const TiXmlElement *node) +void CJabberProto::OmemoHandleDeviceList(const char *from, const TiXmlElement *node) { if (!node) return; - auto *message = node->Parent()->ToElement(); - message = message->Parent()->ToElement(); - - const char *jid = XmlGetAttr(message, "from"); - MCONTACT hContact = HContactFromJID(jid); + MCONTACT hContact = HContactFromJID(from); node = XmlFirstChild(node, "item"); //get node if (!node) { debugLogA("Jabber OMEMO: error: omemo devicelist does not have node"); @@ -1731,7 +1727,7 @@ void CJabberProto::OmemoHandleDeviceList(const TiXmlElement *node) return; } bool own_jid = false; - if (strstr(m_ThreadInfo->fullJID, jid)) + if (strstr(m_ThreadInfo->fullJID, from)) own_jid = true; if (own_jid) { diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 6fe4e59623..ab0ab5e8a0 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -702,7 +702,7 @@ struct CJabberProto : public PROTO, public IJabberInterface void OmemoPutMessageToOutgoingQueue(MCONTACT hContact, int, const char *pszSrc); void OmemoPutMessageToIncommingQueue(const TiXmlElement *node, const char *jid, time_t msgTime); void OmemoHandleMessageQueue(); - void OmemoHandleDeviceList(const TiXmlElement *node); + void OmemoHandleDeviceList(const char *from, const TiXmlElement *node); void OmemoInitDevice(); void OmemoAnnounceDevice(); void OmemoSendBundle(); diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index d1e00a7be4..ed68f22f87 100755 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -940,7 +940,7 @@ void CJabberProto::OnProcessPubsubEvent(const TiXmlElement *node) if (m_bUseOMEMO) { auto *itemsNode = XmlGetChildByTag(eventNode, "items", "node", JABBER_FEAT_OMEMO ".devicelist"); if (itemsNode) { - OmemoHandleDeviceList(itemsNode); + OmemoHandleDeviceList(from, itemsNode); return; } //TODO:handle omemo device list -- cgit v1.2.3