From d6f99a48a6855e8ebc860d069b4c61adbd168f90 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 25 Feb 2023 19:58:46 +0300 Subject: Jabber: ignore m_bEnableVOIP if no Jingle module installed --- protocols/JabberG/src/jabber.cpp | 1 + protocols/JabberG/src/jabber_caps.cpp | 4 ++-- protocols/JabberG/src/jabber_opt.cpp | 5 +++-- protocols/JabberG/src/jabber_proto.cpp | 2 +- protocols/JabberG/src/jabber_proto.h | 4 ++++ protocols/JabberG/src/jabber_thread.cpp | 8 ++++---- protocols/JabberG/src/jabber_voip.cpp | 6 +++--- protocols/JabberG/src/stdafx.h | 2 +- 8 files changed, 19 insertions(+), 13 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index 50dac791a6..b7fd7ae0af 100644 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -94,6 +94,7 @@ static int OnLoadModule(WPARAM, LPARAM) { g_plugin.bMessageState = ServiceExists(MS_MESSAGESTATE_UPDATE); g_plugin.bSecureIM = ServiceExists("SecureIM/IsContactSecured") != 0; + g_plugin.bJingle = ServiceExists(MS_JINGLE_SERVICE); g_plugin.bMirOTR = GetModuleHandle(L"mirotr.dll") != nullptr; g_plugin.bNewGPG = GetModuleHandle(L"new_gpg.dll") != nullptr; return 0; diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index 16ad003a75..57d4cec6b1 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -94,7 +94,7 @@ const JabberFeatCapPairExt g_JabberFeatCapPairsExt[] = { JABBER_EXT_NEWGPG, JABBER_CAPS_NEWGPG, "/ExportGPGKeys" }, { JABBER_EXT_OMEMO, JABBER_CAPS_OMEMO, }, { JABBER_EXT_NUDGE, JABBER_CAPS_ATTENTION, "NUDGE/Send" }, - { JABBER_EXT_JINGLE, JABBER_CAPS_JINGLE, "Jingle/StartSession" }, + { JABBER_EXT_JINGLE, JABBER_CAPS_JINGLE, MS_JINGLE_SERVICE }, { JABBER_EXT_COMMANDS, JABBER_CAPS_COMMANDS }, { JABBER_EXT_USER_ACTIVITY, JABBER_CAPS_USER_ACTIVITY_NOTIFY }, { JABBER_EXT_USER_MOOD, JABBER_CAPS_USER_MOOD_NOTIFY }, @@ -351,7 +351,7 @@ JabberCapsBits CJabberProto::GetOwnCaps(bool IncludeDynamic) jcb |= JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY; if (!m_bMsgAck) jcb &= ~(JABBER_CAPS_CHAT_MARKERS | JABBER_CAPS_MESSAGE_RECEIPTS); - if (m_bEnableVOIP) + if (hasJingle()) jcb |= JABBER_CAPS_JINGLE | JABBER_CAPS_JINGLE_ICEUDP | JABBER_CAPS_JINGLE_RTP | JABBER_CAPS_JINGLE_DTLS | JABBER_CAPS_JINGLE_RTPAUDIO; return jcb; diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index c516232099..5af98f33b2 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -706,7 +706,8 @@ public: m_options.AddOption(LPGENW("Messaging"), LPGENW("Enable server-side history (XEP-0136)"), m_proto->m_bEnableMsgArchive); m_options.AddOption(LPGENW("Messaging"), LPGENW("Enable Message Archive Management (XEP-0313)"), m_proto->m_bEnableMam); m_options.AddOption(LPGENW("Messaging"), LPGENW("Enable carbon copies (XEP-0280)"), m_proto->m_bEnableCarbons); - m_options.AddOption(LPGENW("Messaging"), LPGENW("Enable VOIP (experimental)"), m_proto->m_bEnableVOIP); + if (g_plugin.bJingle) + m_options.AddOption(LPGENW("Messaging"), LPGENW("Enable VOIP (experimental)"), m_proto->m_bEnableVOIP); m_options.AddOption(LPGENW("Server options"), LPGENW("Use Stream Management (XEP-0198) if possible (experimental)"), m_proto->m_bEnableStreamMgmt); m_options.AddOption(LPGENW("Server options"), LPGENW("Disable SASL authentication (for old servers)"), m_proto->m_bDisable3920auth); @@ -772,7 +773,7 @@ public: vsr.name = m_proto->m_szModuleName; vsr.icon = g_plugin.getIconHandle(IDI_NOTES); vsr.flags = 3; - if (m_proto->m_bEnableVOIP) + if (m_proto->hasJingle()) CallService(MS_VOICESERVICE_REGISTER, (WPARAM)&vsr, 0); else { m_proto->VOIPTerminateSession(); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index a00e52b195..dd3a311c90 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -251,7 +251,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : g_plugin.addPopupOption(CMStringW(FORMAT, TranslateT("%s error notifications"), m_tszUserName), m_bUsePopups); // Voip - if (m_bEnableVOIP) { + if (hasJingle()) { VOICE_MODULE vsr = {}; vsr.cbSize = sizeof(VOICE_MODULE); vsr.description = L"XMPP/DTLS-SRTP"; diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 643b432bd0..aa952d4bb0 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -911,6 +911,10 @@ struct CJabberProto : public PROTO, public IJabberInterface struct _GstElement *m_pipe1 = NULL; struct _GstElement *m_webrtc1 = NULL; + __forceinline bool hasJingle() + { return g_plugin.bJingle && m_bEnableVOIP; + } + //---- jabber_xml.c ------------------------------------------------------------------ void OnConsoleProcessXml(const TiXmlElement *node, uint32_t flags); diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp index 6daac6fa9c..908628ae77 100644 --- a/protocols/JabberG/src/jabber_thread.cpp +++ b/protocols/JabberG/src/jabber_thread.cpp @@ -1821,7 +1821,7 @@ bool CJabberProto::OnProcessJingle(const TiXmlElement *node) const TiXmlElement *descr = XmlGetChildByTag(content, "description", "xmlns", JABBER_FEAT_JINGLE_RTP); const char *reason = NULL; - if (m_bEnableVOIP && descr) { + if (hasJingle() && descr) { if (m_voipSession.IsEmpty()) { m_voipSession = szSid; m_voipPeerJid = from; @@ -1869,7 +1869,7 @@ bool CJabberProto::OnProcessJingle(const TiXmlElement *node) return true; } else if (!mir_strcmp(szAction, "session-accept")) { - if (m_bEnableVOIP && m_voipSession == szSid) { + if (hasJingle() && m_voipSession == szSid) { m_ThreadInfo->send(XmlNodeIq("result", idStr, from)); if (OnRTPDescription(child)) { //Make call GUI @@ -1885,7 +1885,7 @@ bool CJabberProto::OnProcessJingle(const TiXmlElement *node) } } else if (!mir_strcmp(szAction, "session-terminate")) { - if (m_bEnableVOIP && m_voipSession == szSid) { + if (hasJingle() && m_voipSession == szSid) { // EndCall() m_ThreadInfo->send(XmlNodeIq("result", idStr, from)); @@ -1903,7 +1903,7 @@ bool CJabberProto::OnProcessJingle(const TiXmlElement *node) } else if (!mir_strcmp(szAction, "transport-info")) { auto *transport = XmlGetChildByTag(content, "transport", "xmlns", JABBER_FEAT_JINGLE_ICEUDP); - if (m_bEnableVOIP && m_voipSession == szSid && transport) { + if (hasJingle() && m_voipSession == szSid && transport) { m_ThreadInfo->send(XmlNodeIq("result", idStr, from)); if (const TiXmlElement *candidate = XmlFirstChild(transport, "candidate")) { OnICECandidate(candidate); diff --git a/protocols/JabberG/src/jabber_voip.cpp b/protocols/JabberG/src/jabber_voip.cpp index 5b65fb269e..43f073ff1b 100644 --- a/protocols/JabberG/src/jabber_voip.cpp +++ b/protocols/JabberG/src/jabber_voip.cpp @@ -276,7 +276,7 @@ void dbgprint(const gchar *string) bool CJabberProto::VOIPCreatePipeline(void) { - if (!m_bEnableVOIP) + if (!hasJingle()) goto err; //gstreamer init @@ -444,7 +444,7 @@ bool CJabberProto::OnRTPDescription(const TiXmlElement *jingleNode) bool CJabberProto::OnICECandidate(const TiXmlElement *Node) { - if (!m_bEnableVOIP) + if (!hasJingle()) return false; CMStringA scandidate; @@ -479,7 +479,7 @@ bool CJabberProto::VOIPCallIinitiate(MCONTACT hContact) return false; } - if (!m_bEnableVOIP) + if (!hasJingle()) return false; CMStringA jid(ptrA(getUStringA(hContact, "jid"))); diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index d848e5a215..a2d0d99205 100644 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -122,7 +122,7 @@ struct CJabberProto; struct CMPlugin : public ACCPROTOPLUGIN { - bool bMessageState = false, bSecureIM = false, bMirOTR = false, bNewGPG = false, bPlatform = false; + bool bMessageState = false, bSecureIM = false, bMirOTR = false, bNewGPG = false, bPlatform = false, bJingle = false; char szRandom[17]; CMPlugin(); -- cgit v1.2.3