diff options
author | George Hazan <george.hazan@gmail.com> | 2023-06-23 16:44:14 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2023-06-23 16:44:14 +0300 |
commit | a07bca6c0e46003a46270999c0c92d3cfef94ee7 (patch) | |
tree | 0704041defd4e09c0355c997ebd84cad6e288d06 /protocols | |
parent | 253e80bc4b440589ead1f756daffa66ad3a045c3 (diff) |
Jingle: first step towards #3351
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/JabberG/src/jabber.cpp | 1 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_api.cpp | 29 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_caps.cpp | 12 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_caps.h | 17 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_opt.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 7 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.h | 11 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_voip.cpp | 7 | ||||
-rw-r--r-- | protocols/JabberG/src/stdafx.h | 3 |
9 files changed, 28 insertions, 61 deletions
diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index 84cbfe2c4e..1c13d97a87 100644 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -95,7 +95,6 @@ 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_api.cpp b/protocols/JabberG/src/jabber_api.cpp index 70c94ead16..ef2b285f70 100644 --- a/protocols/JabberG/src/jabber_api.cpp +++ b/protocols/JabberG/src/jabber_api.cpp @@ -190,18 +190,18 @@ JabberFeatCapPairDynamic *CJabberProto::FindFeature(const char *szFeature) return nullptr;
}
-int CJabberProto::RegisterFeature(const char *szFeature, const char *szDescription)
+int CJabberProto::RegisterFeature(const char *pszFeature, const char *pszDescription, const char *pszExt)
{
- if (!szFeature)
+ if (!pszFeature)
return false;
// check for this feature in core features, and return false if it's present, to prevent re-registering a core feature
for (int i = 0; i < g_cJabberFeatCapPairs; i++)
- if (!mir_strcmp(g_JabberFeatCapPairs[i].szFeature, szFeature))
+ if (!mir_strcmp(g_JabberFeatCapPairs[i].szFeature, pszFeature))
return false;
mir_cslock lck(m_csLists);
- JabberFeatCapPairDynamic *fcp = FindFeature(szFeature);
+ JabberFeatCapPairDynamic *fcp = FindFeature(pszFeature);
if (!fcp) { // if the feature is not registered yet, allocate new bit for it
JabberCapsBits jcb = JABBER_CAPS_OTHER_SPECIAL; // set all bits not included in g_JabberFeatCapPairs
@@ -220,26 +220,17 @@ int CJabberProto::RegisterFeature(const char *szFeature, const char *szDescripti if (!jcb)
return false;
- // remove unnecessary symbols from szFeature to make the string shorter, and use it as szExt
- LPSTR szExt = mir_strdup(szFeature);
- LPSTR pSrc, pDst;
- for (pSrc = szExt, pDst = szExt; *pSrc; pSrc++)
- if (wcschr(L"bcdfghjklmnpqrstvwxz0123456789", *pSrc))
- *pDst++ = *pSrc;
- *pDst = 0;
- g_clientCapsManager.SetClientCaps(JABBER_CAPS_MIRANDA_NODE, m_szFeaturesCrc, szExt, jcb);
+ g_clientCapsManager.SetClientCaps(JABBER_CAPS_MIRANDA_NODE, m_szFeaturesCrc, "", jcb);
fcp = new JabberFeatCapPairDynamic();
- fcp->szExt = szExt; // will be deallocated along with other values of JabberFeatCapPairDynamic in CJabberProto destructor
- fcp->szFeature = mir_strdup(szFeature);
- fcp->szDescription = szDescription ? mir_strdup(szDescription) : nullptr;
+ fcp->szExt = mir_strdup(pszExt);
+ fcp->szFeature = mir_strdup(pszFeature);
+ fcp->szDescription = mir_strdup(pszDescription);
fcp->jcbCap = jcb;
m_lstJabberFeatCapPairsDynamic.insert(fcp);
}
- else if (szDescription) { // update description
- if (fcp->szDescription)
- mir_free(fcp->szDescription);
- fcp->szDescription = mir_strdup(szDescription);
+ else if (pszDescription) { // update description
+ fcp->szDescription = mir_strdup(pszDescription);
}
return true;
}
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp index 57d4cec6b1..852ba4e935 100644 --- a/protocols/JabberG/src/jabber_caps.cpp +++ b/protocols/JabberG/src/jabber_caps.cpp @@ -74,15 +74,10 @@ const JabberFeatCapPair g_JabberFeatCapPairs[] = { JABBER_FEAT_USER_ACTIVITY, JABBER_CAPS_USER_ACTIVITY, LPGEN("Can report information about user activity") },
{ JABBER_FEAT_USER_ACTIVITY_NOTIFY, JABBER_CAPS_USER_ACTIVITY_NOTIFY, LPGEN("Receives information about user activity") },
{ JABBER_FEAT_MIRANDA_NOTES, JABBER_CAPS_MIRANDA_NOTES, LPGEN("Supports Miranda NG notes extension") },
- { JABBER_FEAT_JINGLE, JABBER_CAPS_JINGLE, LPGEN("Supports Jingle") },
{ JABBER_FEAT_ROSTER_EXCHANGE, JABBER_CAPS_ROSTER_EXCHANGE, LPGEN("Supports Roster Exchange") },
{ JABBER_FEAT_DIRECT_MUC_INVITE, JABBER_CAPS_DIRECT_MUC_INVITE, LPGEN("Supports direct chat invitations (XEP-0249)") },
{ JABBER_FEAT_OMEMO_DEVICELIST_NOTIFY, JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY, LPGEN("Receives information about OMEMO devices") },
{ JABBER_FEAT_CARBONS, JABBER_CAPS_CARBONS, LPGEN("Supports message carbons (XEP-0280)")},
- { JABBER_FEAT_JINGLE_ICEUDP, JABBER_CAPS_JINGLE_ICEUDP, LPGEN("Jingle ICE-UDP Transport") },
- { JABBER_FEAT_JINGLE_RTP, JABBER_CAPS_JINGLE_RTP, LPGEN("Jingle RTP") },
- { JABBER_FEAT_JINGLE_DTLS, JABBER_CAPS_JINGLE_DTLS, LPGEN("Jingle DTLS") },
- { JABBER_FEAT_JINGLE_RTPAUDIO, JABBER_CAPS_JINGLE_RTPAUDIO, LPGEN("Jingle RTP Audio") },
};
const int g_cJabberFeatCapPairs = _countof(g_JabberFeatCapPairs);
@@ -94,7 +89,6 @@ 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, 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,8 +345,6 @@ JabberCapsBits CJabberProto::GetOwnCaps(bool IncludeDynamic) jcb |= JABBER_CAPS_OMEMO_DEVICELIST_NOTIFY;
if (!m_bMsgAck)
jcb &= ~(JABBER_CAPS_CHAT_MARKERS | JABBER_CAPS_MESSAGE_RECEIPTS);
- if (hasJingle())
- jcb |= JABBER_CAPS_JINGLE | JABBER_CAPS_JINGLE_ICEUDP | JABBER_CAPS_JINGLE_RTP | JABBER_CAPS_JINGLE_DTLS | JABBER_CAPS_JINGLE_RTPAUDIO;
return jcb;
}
@@ -417,8 +409,8 @@ void CJabberProto::UpdateFeatHash() /////////////////////////////////////////////////////////////////////////////////////////
// CJabberClientPartialCaps class
-CJabberClientPartialCaps::CJabberClientPartialCaps(CJabberClientCaps *pParent, const char *szHash, const char *szVer)
- : m_parent(pParent),
+CJabberClientPartialCaps::CJabberClientPartialCaps(CJabberClientCaps *pParent, const char *szHash, const char *szVer) :
+ m_parent(pParent),
m_szHash(mir_strdup(szHash)),
m_szSoftVer(mir_strdup(szVer))
{
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h index e8ceccf4a0..66d0ecf2b8 100644 --- a/protocols/JabberG/src/jabber_caps.h +++ b/protocols/JabberG/src/jabber_caps.h @@ -165,9 +165,6 @@ typedef unsigned __int64 JabberCapsBits; #define JABBER_FEAT_MIRANDA_NOTES "http://miranda-ng.org/storage#notes"
#define JABBER_CAPS_MIRANDA_NOTES ((JabberCapsBits)1<<39)
-#define JABBER_FEAT_JINGLE "urn:xmpp:jingle:1"
-#define JABBER_CAPS_JINGLE ((JabberCapsBits)1<<40)
-
#define JABBER_FEAT_ROSTER_EXCHANGE "http://jabber.org/protocol/rosterx"
#define JABBER_CAPS_ROSTER_EXCHANGE ((JabberCapsBits)1<<41)
@@ -195,15 +192,6 @@ typedef unsigned __int64 JabberCapsBits; #define JABBER_FEAT_BITS "urn:xmpp:bob"
#define JABBER_CAPS_BITS ((JabberCapsBits)1<<50)
-#define JABBER_FEAT_JINGLE_ICEUDP "urn:xmpp:jingle:transports:ice-udp:1"
-#define JABBER_CAPS_JINGLE_ICEUDP ((JabberCapsBits)1<<51)
-#define JABBER_FEAT_JINGLE_RTP "urn:xmpp:jingle:apps:rtp:1"
-#define JABBER_CAPS_JINGLE_RTP ((JabberCapsBits)1<<52)
-#define JABBER_FEAT_JINGLE_DTLS "urn:xmpp:jingle:apps:dtls:0"
-#define JABBER_CAPS_JINGLE_DTLS ((JabberCapsBits)1<<53)
-#define JABBER_FEAT_JINGLE_RTPAUDIO "urn:xmpp:jingle:apps:rtp:audio"
-#define JABBER_CAPS_JINGLE_RTPAUDIO ((JabberCapsBits)1<<54)
-
#define JABBER_FEAT_ARCHIVE "urn:xmpp:archive"
#define JABBER_FEAT_BIND "urn:ietf:params:xml:ns:xmpp-bind"
#define JABBER_FEAT_CAPTCHA "urn:xmpp:captcha"
@@ -237,7 +225,6 @@ typedef unsigned __int64 JabberCapsBits; #define JABBER_EXT_SECUREIM "secureim"
#define JABBER_EXT_MIROTR "mirotr"
-#define JABBER_EXT_JINGLE "jingle"
#define JABBER_EXT_NEWGPG "new_gpg"
#define JABBER_EXT_OMEMO "omemo"
#define JABBER_EXT_NUDGE "nudge"
@@ -381,10 +368,8 @@ struct JabberFeatCapPairExt struct JabberFeatCapPairDynamic
{
- char *szExt;
- char *szFeature;
+ ptrA szFeature, szDescription, szExt;
JabberCapsBits jcbCap;
- char *szDescription;
};
extern const int g_cJabberFeatCapPairs;
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp index e5c570e589..b0bc6d6342 100644 --- a/protocols/JabberG/src/jabber_opt.cpp +++ b/protocols/JabberG/src/jabber_opt.cpp @@ -707,7 +707,7 @@ public: m_options.AddOption(LPGENW("Messaging"), LPGENW("Enable carbon copies (XEP-0280)"), m_proto->m_bEnableCarbons);
if (mir_strlen(ptrA(m_proto->getStringA("HttpUpload"))))
m_options.AddOption(LPGENW("Messaging"), LPGENW("Enable HTTP File Upload (XEP-0363)"), m_proto->m_bUseHttpUpload);
- if (g_plugin.bJingle)
+ if (m_proto->hasJingle())
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);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 99a1ff1688..b094f85590 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -283,12 +283,7 @@ CJabberProto::~CJabberProto() for (auto &it : m_lstTransports)
mir_free(it);
- for (auto &it : m_lstJabberFeatCapPairsDynamic) {
- mir_free(it->szExt);
- mir_free(it->szFeature);
- mir_free(it->szDescription);
- delete it;
- }
+ m_lstJabberFeatCapPairsDynamic.destroy();
}
////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index 4d8291177d..b5a882df24 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -307,9 +307,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface mir_cs m_csLists;
BOOL m_bListInitialised;
- LIST<JabberFeatCapPairDynamic> m_lstJabberFeatCapPairsDynamic; // list of features registered through IJabberNetInterface::RegisterFeature()
- JabberCapsBits m_uEnabledFeatCapsDynamic;
-
+ // menus
HGENMENU m_hMenuRoot;
HGENMENU m_hMenuChangePassword;
HGENMENU m_hMenuGroupchat;
@@ -424,6 +422,8 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface int ByteSendProxyParse(HNETLIBCONN hConn, JABBER_BYTE_TRANSFER *jbt, char* buffer, int datalen);
//---- jabber_caps.cpp ---------------------------------------------------------------
+ OBJLIST<JabberFeatCapPairDynamic> m_lstJabberFeatCapPairsDynamic; // list of features registered through IJabberNetInterface::RegisterFeature()
+ JabberCapsBits m_uEnabledFeatCapsDynamic;
CMStringA m_szFeaturesCrc;
@@ -724,7 +724,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface bool OmemoHandleMessage(const TiXmlElement *node, const char *jid, time_t msgTime, bool isCarbon);
void OmemoPutMessageToOutgoingQueue(MCONTACT hContact, const char *pszSrc);
- void OmemoPutMessageToIncommingQueue(const TiXmlElement *node, const char *jid, time_t msgTime);
void OmemoHandleMessageQueue();
bool OmemoHandleDeviceList(const char *from, const TiXmlElement *node);
void OmemoInitDevice();
@@ -920,7 +919,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface struct _GstElement *m_webrtc1 = NULL;
__forceinline bool hasJingle()
- { return g_plugin.bJingle && m_bEnableVOIP;
+ { return FindFeature(JABBER_FEAT_JINGLE) != 0 && m_bEnableVOIP;
}
//---- jabber_xml.c ------------------------------------------------------------------
@@ -990,7 +989,7 @@ public: HJHANDLER STDMETHODCALLTYPE AddSendHandler(JABBER_HANDLER_FUNC Func, void *pUserData, int iPriority) override;
int STDMETHODCALLTYPE RemoveHandler(HJHANDLER hHandler) override;
- int STDMETHODCALLTYPE RegisterFeature(const char *szFeature, const char *szDescription) override;
+ int STDMETHODCALLTYPE RegisterFeature(const char *szFeature, const char *szDescription, const char *ext = 0) override;
int STDMETHODCALLTYPE AddFeatures(const char *szFeatures) override; // Adds features to the list of features returned by the client.
int STDMETHODCALLTYPE RemoveFeatures(const char *szFeatures) override; // Removes features from the list of features returned by the client.
char* STDMETHODCALLTYPE GetResourceFeatures(const char *jid) override; // Returns all features supported by JID in format "feature1\0feature2\0...\0featureN\0\0". You must free returned string using mir_free().
diff --git a/protocols/JabberG/src/jabber_voip.cpp b/protocols/JabberG/src/jabber_voip.cpp index 85d8ad3f12..9c8cb589d9 100644 --- a/protocols/JabberG/src/jabber_voip.cpp +++ b/protocols/JabberG/src/jabber_voip.cpp @@ -490,7 +490,12 @@ bool CJabberProto::VOIPCallIinitiate(MCONTACT hContact) auto r = ListGetBestResource(jid); if (r) { - if (!(r->m_pCaps->GetCaps() & JABBER_CAPS_JINGLE)) { + bool bFound = false; + if (auto *pFeature = FindFeature(JABBER_FEAT_JINGLE)) + if (!(r->m_pCaps->GetCaps() & pFeature->jcbCap)) + bFound = true; + + if (!bFound) { MsgPopup(hContact, TranslateT("Client's program does not support voice calls"), TranslateT("Error")); return false; } diff --git a/protocols/JabberG/src/stdafx.h b/protocols/JabberG/src/stdafx.h index 384f300be8..82b719af32 100644 --- a/protocols/JabberG/src/stdafx.h +++ b/protocols/JabberG/src/stdafx.h @@ -70,6 +70,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_hotkeys.h>
#include <m_icolib.h>
#include <m_idle.h>
+#include <m_jingle.h>
#include <m_json.h>
#include <m_langpack.h>
#include <m_message.h>
@@ -121,7 +122,7 @@ struct CJabberProto; struct CMPlugin : public ACCPROTOPLUGIN<CJabberProto>
{
- bool bMessageState = false, bSecureIM = false, bMirOTR = false, bNewGPG = false, bPlatform = false, bJingle = false;
+ bool bMessageState = false, bSecureIM = false, bMirOTR = false, bNewGPG = false, bPlatform = false;
char szRandom[17];
CMPlugin();
|