From a07bca6c0e46003a46270999c0c92d3cfef94ee7 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 23 Jun 2023 16:44:14 +0300 Subject: Jingle: first step towards #3351 --- plugins/ExternalAPI/m_jingle.h | 10 ++++++ plugins/Jingle/Jingle.vcxproj | 3 ++ plugins/Jingle/Jingle.vcxproj.filters | 8 ++++- plugins/Jingle/src/account.cpp | 62 +++++++++++++++++++++++++++++++++++ plugins/Jingle/src/account.h | 18 ++++++++++ plugins/Jingle/src/main.cpp | 8 +++-- plugins/Jingle/src/stdafx.h | 2 ++ plugins/Jingle/src/version.h | 2 +- 8 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 plugins/ExternalAPI/m_jingle.h create mode 100644 plugins/Jingle/src/account.cpp create mode 100644 plugins/Jingle/src/account.h (limited to 'plugins') diff --git a/plugins/ExternalAPI/m_jingle.h b/plugins/ExternalAPI/m_jingle.h new file mode 100644 index 0000000000..1d8718fa58 --- /dev/null +++ b/plugins/ExternalAPI/m_jingle.h @@ -0,0 +1,10 @@ +#ifndef __m_jingle__ +#define __m_jingle__ + +#define JABBER_FEAT_JINGLE "urn:xmpp:jingle:1" +#define JABBER_FEAT_JINGLE_ICEUDP "urn:xmpp:jingle:transports:ice-udp:1" +#define JABBER_FEAT_JINGLE_RTP "urn:xmpp:jingle:apps:rtp:1" +#define JABBER_FEAT_JINGLE_DTLS "urn:xmpp:jingle:apps:dtls:0" +#define JABBER_FEAT_JINGLE_RTPAUDIO "urn:xmpp:jingle:apps:rtp:audio" + +#endif // __m_jingle__ diff --git a/plugins/Jingle/Jingle.vcxproj b/plugins/Jingle/Jingle.vcxproj index 1ad612cac7..0f061b8cfe 100644 --- a/plugins/Jingle/Jingle.vcxproj +++ b/plugins/Jingle/Jingle.vcxproj @@ -31,10 +31,13 @@ + Create + + diff --git a/plugins/Jingle/Jingle.vcxproj.filters b/plugins/Jingle/Jingle.vcxproj.filters index df6abcafef..947797218d 100644 --- a/plugins/Jingle/Jingle.vcxproj.filters +++ b/plugins/Jingle/Jingle.vcxproj.filters @@ -8,7 +8,7 @@ Source Files - + Source Files @@ -19,6 +19,12 @@ Header Files + + Header Files + + + Header Files + diff --git a/plugins/Jingle/src/account.cpp b/plugins/Jingle/src/account.cpp new file mode 100644 index 0000000000..551f59db00 --- /dev/null +++ b/plugins/Jingle/src/account.cpp @@ -0,0 +1,62 @@ +/* +Copyright (C) 2012-23 Miranda NG team (https://miranda-ng.org) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation version 2 +of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*/ + +#include "stdafx.h" + +static int OnModulesLoaded(WPARAM, LPARAM) +{ + for (auto &it : Accounts()) + if (auto *pApi = getJabberApi(it->szModuleName)) { + auto *pAccount = new CJabberAccount(pApi); + g_arJabber.insert(pAccount); + pAccount->Init(); + } + + return 0; +} + +static int OnAccountCreated(WPARAM reason, LPARAM param) +{ + if (reason == PRAC_ADDED) { + auto *pa = (PROTOACCOUNT *)param; + if (auto *pApi = getJabberApi(pa->szModuleName)) { + auto *pAccount = new CJabberAccount(pApi); + g_arJabber.insert(pAccount); + pAccount->Init(); + } + } + return 0; +} + +void CJabberAccount::InitHooks() +{ + HookEvent(ME_SYSTEM_MODULESLOADED, &OnModulesLoaded); + HookEvent(ME_PROTO_ACCLISTCHANGED, &OnAccountCreated); +} + +/////////////////////////////////////////////////////////////////////////////// + +void CJabberAccount::Init() +{ + m_api->RegisterFeature(JABBER_FEAT_JINGLE, LPGEN("Supports Jingle"), "jingle"); + m_api->RegisterFeature(JABBER_FEAT_JINGLE_ICEUDP, LPGEN("Jingle ICE-UDP Transport")); + m_api->RegisterFeature(JABBER_FEAT_JINGLE_RTP, LPGEN("Jingle RTP")); + m_api->RegisterFeature(JABBER_FEAT_JINGLE_DTLS, LPGEN("Jingle DTLS")); + m_api->RegisterFeature(JABBER_FEAT_JINGLE_RTPAUDIO, LPGEN("Jingle RTP Audio")); + + m_api->AddFeatures(JABBER_FEAT_JINGLE "\0" JABBER_FEAT_JINGLE_ICEUDP "\0" JABBER_FEAT_JINGLE_RTP "\0" JABBER_FEAT_JINGLE_DTLS "\0" JABBER_FEAT_JINGLE_RTPAUDIO "\0\0"); +} diff --git a/plugins/Jingle/src/account.h b/plugins/Jingle/src/account.h new file mode 100644 index 0000000000..8302f8e3f2 --- /dev/null +++ b/plugins/Jingle/src/account.h @@ -0,0 +1,18 @@ +#ifndef _ACCOUNT_H +#define _ACCOUNT_H + +struct CJabberAccount +{ + CJabberAccount(IJabberInterface *_1) : + m_api(_1) + {} + + IJabberInterface *m_api; + + void Init(); + static void InitHooks(); +}; + +extern OBJLIST g_arJabber; + +#endif //_ACCOUNT_H \ No newline at end of file diff --git a/plugins/Jingle/src/main.cpp b/plugins/Jingle/src/main.cpp index 5936eb7fc9..016244ad29 100644 --- a/plugins/Jingle/src/main.cpp +++ b/plugins/Jingle/src/main.cpp @@ -2,6 +2,8 @@ CMPlugin g_plugin; +OBJLIST g_arJabber(1); + ///////////////////////////////////////////////////////////////////////////////////////// PLUGININFOEX pluginInfoEx = { @@ -23,7 +25,7 @@ CMPlugin::CMPlugin() : } ///////////////////////////////////////////////////////////////////////////////////////// -// Load (hook ModulesLoaded) +// Load static INT_PTR FakeService(WPARAM, LPARAM) { @@ -40,6 +42,8 @@ int CMPlugin::Load() { SetEnvironmentVariableW(L"GST_PLUGIN_PATH", VARSW(L"%miranda_path%\\Libs\\gst_plugins")); - CreateServiceFunction(MS_JINGLE_SERVICE, &FakeService); + CreateServiceFunction("JINGLE/SERVICE", &FakeService); + + CJabberAccount::InitHooks(); return 0; } diff --git a/plugins/Jingle/src/stdafx.h b/plugins/Jingle/src/stdafx.h index ace5347f03..ff0b86c4b9 100644 --- a/plugins/Jingle/src/stdafx.h +++ b/plugins/Jingle/src/stdafx.h @@ -21,10 +21,12 @@ #include #include +#include #include #include #include +#include "account.h" #include "resource.h" #include "version.h" diff --git a/plugins/Jingle/src/version.h b/plugins/Jingle/src/version.h index 4966be0dde..4e88b19d46 100644 --- a/plugins/Jingle/src/version.h +++ b/plugins/Jingle/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 0 #define __RELEASE_NUM 0 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3