From eb6981dc2146cc8718eb913605fac6b9c3746642 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 16 Mar 2023 20:35:01 +0300 Subject: Jabber: OMEMO device list request moved to the separate function --- protocols/JabberG/src/jabber_iqid.cpp | 10 ++-------- protocols/JabberG/src/jabber_omemo.cpp | 16 ++++++++++++++++ protocols/JabberG/src/jabber_proto.cpp | 1 + protocols/JabberG/src/jabber_proto.h | 1 + protocols/JabberG/src/jabber_thread.cpp | 9 --------- protocols/JabberG/src/jabber_vcard.cpp | 1 + 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index d286205029..1498dad982 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -108,14 +108,8 @@ void CJabberProto::OnIqResultServerDiscoInfo(const TiXmlElement *iqNode, CJabber if (!mir_strcmp(tmp.category, "pubsub") && !mir_strcmp(tmp.type, "pep")) { m_bPepSupported = true; - if (m_bUseOMEMO) { - XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultGetOmemodevicelist, JABBER_IQ_TYPE_GET)); - iq << XATTR("from", m_ThreadInfo->fullJID); - iq << XCHILDNS("pubsub", "http://jabber.org/protocol/pubsub") - << XCHILD("items") << XATTR("node", JABBER_FEAT_OMEMO ".devicelist"); - - m_ThreadInfo->send(iq); - } + if (m_bUseOMEMO) + OmemoRequestDeviceList(nullptr); EnableMenuItems(true); continue; diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index 6dc9fa2d8d..1518e3e24d 100644 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -1996,3 +1996,19 @@ bool CJabberProto::OmemoIsEnabled(MCONTACT hContact) { return !getByte(hContact, "bDisableOmemo"); } + +void CJabberProto::OmemoRequestDeviceList(const char *szBareJid) +{ + if (!m_bJabberOnline) + return; + + if (szBareJid && strchr(szBareJid, '/')) + return; + + XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultGetOmemodevicelist, JABBER_IQ_TYPE_GET)); + if (szBareJid) + iq << XATTR("to", szBareJid); + iq << XCHILDNS("pubsub", "http://jabber.org/protocol/pubsub") + << XCHILD("items") << XATTR("node", JABBER_FEAT_OMEMO ".devicelist"); + m_ThreadInfo->send(iq); +} diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index a50e100b87..282672e4ea 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -700,6 +700,7 @@ int CJabberProto::GetInfo(MCONTACT hContact, int /*infoType*/) } SendGetVcard(hContact); + OmemoRequestDeviceList(jid); return 0; } diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 309a5c0677..f940f3349d 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -731,6 +731,7 @@ struct CJabberProto : public PROTO, public IJabberInterface int OmemoEncryptMessage(XmlNode &msg, const char *msg_text, MCONTACT hContact); bool OmemoIsEnabled(MCONTACT hContact); void OmemoOnIqResultGetBundle(const TiXmlElement *iqNode, CJabberIqInfo *pInfo); + void OmemoRequestDeviceList(const char * szBareJid); omemo::omemo_impl m_omemo; diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index eb8d34d2c9..02a5bc4b28 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1597,15 +1597,6 @@ void CJabberProto::OnProcessPresence(const TiXmlElement *node, ThreadData *info) hContact = DBCreateContact(from, nick, true, true); } - if (hContact && m_bUseOMEMO) { - XmlNodeIq iq(AddIQ(&CJabberProto::OnIqResultGetOmemodevicelist, JABBER_IQ_TYPE_GET)); - iq << XATTR("from", szBareOurJid); - iq << XATTR("to", szBareFrom); - iq << XCHILDNS("pubsub", "http://jabber.org/protocol/pubsub") - << XCHILD("items") << XATTR("node", JABBER_FEAT_OMEMO ".devicelist"); - m_ThreadInfo->send(iq); - } - if (!ListGetItemPtr(LIST_ROSTER, from)) { debugLogA("Receive presence online from %s (who is not in my roster)", from); ListAdd(LIST_ROSTER, from, hContact); diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index ff7f3e9212..f5d8b66428 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -1063,4 +1063,5 @@ void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM) CheckOmemoUserInfo(wParam, uip); SendGetVcard(0); + OmemoRequestDeviceList(nullptr); } -- cgit v1.2.3