summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-03-15 22:03:48 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-03-15 22:03:48 +0300
commit3d155d30b429a0525c6cc5860c1a04980450f687 (patch)
treea3e2a69e9b7b56a4ad8f8a98cb9cb5e50e501354
parent856b25dbea6b4f772c236d674fb83ddbed5f9d14 (diff)
Jabber: minor OMEMO code optimization
-rwxr-xr-xprotocols/JabberG/src/jabber_omemo.cpp10
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.h2
-rwxr-xr-xprotocols/JabberG/src/jabber_thread.cpp2
3 files changed, 5 insertions, 9 deletions
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 <item> node
if (!node) {
debugLogA("Jabber OMEMO: error: omemo devicelist does not have <item> 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<CJabberProto>, 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