summaryrefslogtreecommitdiff
path: root/protocols/Discord
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-03-11 19:51:38 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-03-11 19:51:38 +0300
commit367731ae14fcc861178a20527ee8be83b91f8ef3 (patch)
treec5d25c003f1ed09dc88f3236bf832898af8ea4c4 /protocols/Discord
parente8fb7de563970da12871b83c0c5e84775fe71d2d (diff)
Discord: partial support for VoiceService plugin
Diffstat (limited to 'protocols/Discord')
-rw-r--r--protocols/Discord/src/main.cpp10
-rw-r--r--protocols/Discord/src/proto.cpp14
-rw-r--r--protocols/Discord/src/proto.h2
-rw-r--r--protocols/Discord/src/stdafx.h10
4 files changed, 31 insertions, 5 deletions
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<CDiscordProto>
{
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 <m_system.h>
#include <newpluginapi.h>
+#include <m_avatars.h>
#include <m_chat_int.h>
#include <m_clist.h>
#include <m_contacts.h>
@@ -27,6 +28,9 @@
#include <m_folders.h>
#include <m_gui.h>
#include <m_history.h>
+#include <m_hotkeys.h>
+#include <m_icolib.h>
+#include <m_json.h>
#include <m_langpack.h>
#include <m_message.h>
#include <m_netlib.h>
@@ -38,11 +42,9 @@
#include <m_skin.h>
#include <m_srmm_int.h>
#include <m_userinfo.h>
-#include <m_icolib.h>
#include <m_utils.h>
-#include <m_hotkeys.h>
-#include <m_json.h>
-#include <m_avatars.h>
+#include <m_voice.h>
+#include <m_voiceservice.h>
#include <win2k.h>
#include "../../libs/zlib/src/zlib.h"