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 /plugins/Jingle | |
parent | 253e80bc4b440589ead1f756daffa66ad3a045c3 (diff) |
Jingle: first step towards #3351
Diffstat (limited to 'plugins/Jingle')
-rw-r--r-- | plugins/Jingle/Jingle.vcxproj | 3 | ||||
-rw-r--r-- | plugins/Jingle/Jingle.vcxproj.filters | 8 | ||||
-rw-r--r-- | plugins/Jingle/src/account.cpp | 62 | ||||
-rw-r--r-- | plugins/Jingle/src/account.h | 18 | ||||
-rw-r--r-- | plugins/Jingle/src/main.cpp | 8 | ||||
-rw-r--r-- | plugins/Jingle/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/Jingle/src/version.h | 2 |
7 files changed, 99 insertions, 4 deletions
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 @@ </ClCompile> </ItemDefinitionGroup> <ItemGroup> + <ClCompile Include="src\account.cpp" /> <ClCompile Include="src\main.cpp" /> <ClCompile Include="src\stdafx.cxx"> <PrecompiledHeader>Create</PrecompiledHeader> </ClCompile> + <ClInclude Include="..\ExternalAPI\m_jingle.h" /> + <ClInclude Include="src\account.h" /> <ClInclude Include="src\stdafx.h" /> <ClInclude Include="src\version.h" /> </ItemGroup> 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 @@ <ClCompile Include="src\stdafx.cxx"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="src\voip.cpp"> + <ClCompile Include="src\account.cpp"> <Filter>Source Files</Filter> </ClCompile> </ItemGroup> @@ -19,6 +19,12 @@ <ClInclude Include="src\version.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="src\account.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\ExternalAPI\m_jingle.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <ResourceCompile Include="res\Version.rc"> 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 <http://www.gnu.org/licenses/>. +*/ + +#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<CJabberAccount> 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<CJabberAccount> 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 <newpluginapi.h> #include <m_jabber.h> +#include <m_jingle.h> #include <m_langpack.h> #include <m_voice.h> #include <m_voiceservice.h> +#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 <stdver.h> |