From 367731ae14fcc861178a20527ee8be83b91f8ef3 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 11 Mar 2020 19:51:38 +0300 Subject: Discord: partial support for VoiceService plugin --- protocols/Discord/src/main.cpp | 10 +++++++++- protocols/Discord/src/proto.cpp | 14 ++++++++++++++ protocols/Discord/src/proto.h | 2 ++ protocols/Discord/src/stdafx.h | 10 ++++++---- 4 files changed, 31 insertions(+), 5 deletions(-) (limited to 'protocols/Discord') diff --git a/protocols/Discord/src/main.cpp b/protocols/Discord/src/main.cpp index a5d871b162..e031b3ca4d 100644 --- a/protocols/Discord/src/main.cpp +++ b/protocols/Discord/src/main.cpp @@ -52,12 +52,20 @@ IconItem g_iconList[] = { { LPGEN("Main icon"), "main", IDI_MAIN }, { LPGEN("Group chats"), "groupchat", IDI_GROUPCHAT }, - { LPGEN("Call"), "voicecall", IDI_VOICE_CALL }, + { LPGEN("Call"), "voicecall", IDI_VOICE_CALL }, { LPGEN("Call ended"), "voiceend", IDI_VOICE_ENDED } }; +static int OnModulesLoaded(WPARAM, LPARAM) +{ + g_plugin.bVoiceService = ServiceExists(MS_VOICESERVICE_REGISTER); + return 0; +} + int CMPlugin::Load() { + HookEvent(ME_SYSTEM_MODULESLOADED, &OnModulesLoaded); + g_plugin.registerIcon("Protocols/Discord", g_iconList); return 0; } diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp index 98258c6b7d..25cfdaffdc 100644 --- a/protocols/Discord/src/proto.cpp +++ b/protocols/Discord/src/proto.cpp @@ -153,6 +153,17 @@ void CDiscordProto::OnModulesLoaded() HookProtoEvent(ME_GC_BUILDMENU, &CDiscordProto::GroupchatMenuHook); InitMenus(); + + // Voice support + if (g_plugin.bVoiceService) { + VOICE_MODULE voice = {}; + voice.cbSize = sizeof(voice); + voice.name = m_szModuleName; + voice.description = TranslateT("Discord voice call"); + voice.icon = m_hProtoIcon; + voice.flags = VOICE_CAPS_CALL_CONTACT | VOICE_CAPS_VOICE; + CallService(MS_VOICESERVICE_REGISTER, (WPARAM)&voice, 0); + } } void CDiscordProto::OnShutdown() @@ -164,6 +175,9 @@ void CDiscordProto::OnShutdown() if (m_hGatewayConnection) Netlib_Shutdown(m_hGatewayConnection); + + if (g_plugin.bVoiceService) + CallService(MS_VOICESERVICE_UNREGISTER, (WPARAM)m_szModuleName, 0); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index c6e51cb341..d1a15f63f4 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -445,5 +445,7 @@ struct CMPlugin : public ACCPROTOPLUGIN { CMPlugin(); + bool bVoiceService = false; + int Load() override; }; diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h index c05bfb8167..1a2cbc3278 100644 --- a/protocols/Discord/src/stdafx.h +++ b/protocols/Discord/src/stdafx.h @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -38,11 +42,9 @@ #include #include #include -#include #include -#include -#include -#include +#include +#include #include #include "../../libs/zlib/src/zlib.h" -- cgit v1.2.3