summaryrefslogtreecommitdiff
path: root/protocols/Discord/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r--protocols/Discord/src/main.cpp4
-rw-r--r--protocols/Discord/src/menus.cpp47
-rw-r--r--protocols/Discord/src/proto.cpp3
-rw-r--r--protocols/Discord/src/proto.h6
-rw-r--r--protocols/Discord/src/stdafx.h1
5 files changed, 33 insertions, 28 deletions
diff --git a/protocols/Discord/src/main.cpp b/protocols/Discord/src/main.cpp
index 023a7b7925..08d8c27dbe 100644
--- a/protocols/Discord/src/main.cpp
+++ b/protocols/Discord/src/main.cpp
@@ -19,6 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
CMPlugin g_plugin;
+HGENMENU g_hMenuLeaveGuild, g_hMenuCreateChannel, g_hMenuToggleSync, g_hMenuDatabaseHistory;
+
/////////////////////////////////////////////////////////////////////////////////////////
PLUGININFOEX pluginInfoEx = {
@@ -79,6 +81,8 @@ int CMPlugin::Load()
HookEvent(ME_SYSTEM_MODULESLOADED, &OnModulesLoaded);
+ CDiscordProto::InitMenus();
+
g_plugin.registerIcon("Protocols/Discord", g_iconList);
return 0;
}
diff --git a/protocols/Discord/src/menus.cpp b/protocols/Discord/src/menus.cpp
index 13c5f204d9..6386d32a4a 100644
--- a/protocols/Discord/src/menus.cpp
+++ b/protocols/Discord/src/menus.cpp
@@ -106,23 +106,23 @@ int CDiscordProto::OnMenuPrebuild(WPARAM hContact, LPARAM)
{
// "Leave guild" menu item should be visible only for the guild contacts
bool bIsGuild = getByte(hContact, "ChatRoom") == 2;
- Menu_ShowItem(m_hMenuLeaveGuild, bIsGuild);
- Menu_ShowItem(m_hMenuCreateChannel, bIsGuild);
- Menu_ShowItem(m_hMenuToggleSync, bIsGuild);
- Menu_ShowItem(m_hMenuDatabaseHistory, bIsGuild);
+ Menu_ShowItem(g_hMenuLeaveGuild, bIsGuild);
+ Menu_ShowItem(g_hMenuCreateChannel, bIsGuild);
+ Menu_ShowItem(g_hMenuToggleSync, bIsGuild);
+ Menu_ShowItem(g_hMenuDatabaseHistory, bIsGuild);
if (!bIsGuild && getWord(hContact, "ApparentMode") != 0)
Menu_ShowItem(GetMenuItem(PROTO_MENU_REQ_AUTH), true);
if (getByte(hContact, DB_KEY_ENABLE_SYNC))
- Menu_ModifyItem(m_hMenuToggleSync, LPGENW("Disable sync"), Skin_GetIconHandle(SKINICON_CHAT_LEAVE));
+ Menu_ModifyItem(g_hMenuToggleSync, LPGENW("Disable sync"), Skin_GetIconHandle(SKINICON_CHAT_LEAVE));
else
- Menu_ModifyItem(m_hMenuToggleSync, LPGENW("Enable sync"), Skin_GetIconHandle(SKINICON_CHAT_JOIN));
+ Menu_ModifyItem(g_hMenuToggleSync, LPGENW("Enable sync"), Skin_GetIconHandle(SKINICON_CHAT_JOIN));
if (getByte(hContact, DB_KEY_ENABLE_HIST))
- Menu_ModifyItem(m_hMenuDatabaseHistory, LPGENW("Disable database history for a guild"), Skin_GetIconHandle(SKINICON_CHAT_LEAVE));
+ Menu_ModifyItem(g_hMenuDatabaseHistory, LPGENW("Disable database history for a guild"), Skin_GetIconHandle(SKINICON_CHAT_LEAVE));
else
- Menu_ModifyItem(m_hMenuDatabaseHistory, LPGENW("Enable database history for a guild"), Skin_GetIconHandle(SKINICON_CHAT_JOIN));
+ Menu_ModifyItem(g_hMenuDatabaseHistory, LPGENW("Enable database history for a guild"), Skin_GetIconHandle(SKINICON_CHAT_JOIN));
return 0;
}
@@ -156,44 +156,43 @@ void CDiscordProto::OnBuildProtoMenu()
void CDiscordProto::InitMenus()
{
CMenuItem mi(&g_plugin);
- mi.pszService = "/LeaveGuild";
- CreateProtoService(mi.pszService, &CDiscordProto::OnMenuLeaveGuild);
+ mi.pszService = "/Discord/LeaveGuild";
+ CreateServiceFunction(mi.pszService, GlobalService<&CDiscordProto::OnMenuLeaveGuild>);
SET_UID(mi, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8C);
mi.name.a = LPGEN("Leave guild");
mi.position = -200001000;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_CHAT_LEAVE);
- m_hMenuLeaveGuild = Menu_AddContactMenuItem(&mi, m_szModuleName);
+ g_hMenuLeaveGuild = Menu_AddContactMenuItem(&mi);
- mi.pszService = "/CreateChannel";
- CreateProtoService(mi.pszService, &CDiscordProto::OnMenuCreateChannel);
+ mi.pszService = "/Discord/CreateChannel";
+ CreateServiceFunction(mi.pszService, GlobalService<&CDiscordProto::OnMenuCreateChannel>);
SET_UID(mi, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8D);
mi.name.a = LPGEN("Create new channel");
mi.position++;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_ADDCONTACT);
- m_hMenuCreateChannel = Menu_AddContactMenuItem(&mi, m_szModuleName);
+ g_hMenuCreateChannel = Menu_AddContactMenuItem(&mi);
SET_UID(mi, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8E);
- mi.pszService = "/CopyId";
+ CreateServiceFunction(mi.pszService, GlobalService<&CDiscordProto::OnMenuCopyId>);
+ mi.pszService = "/Discord/CopyId";
mi.name.a = LPGEN("Copy ID");
mi.position++;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_USERONLINE);
- Menu_AddContactMenuItem(&mi, m_szModuleName);
+ Menu_AddContactMenuItem(&mi);
- mi.pszService = "/ToggleSync";
- CreateProtoService(mi.pszService, &CDiscordProto::OnMenuToggleSync);
+ mi.pszService = "/Discord/ToggleSync";
+ CreateServiceFunction(mi.pszService, GlobalService<&CDiscordProto::OnMenuToggleSync>);
SET_UID(mi, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8F);
mi.name.a = LPGEN("Enable guild sync");
mi.position++;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_CHAT_JOIN);
- m_hMenuToggleSync = Menu_AddContactMenuItem(&mi, m_szModuleName);
+ g_hMenuToggleSync = Menu_AddContactMenuItem(&mi);
- mi.pszService = "/DatabaseHistory";
- CreateProtoService(mi.pszService, &CDiscordProto::OnMenuDatabaseHistory);
+ mi.pszService = "/Discord/DatabaseHistory";
+ CreateServiceFunction(mi.pszService, GlobalService<&CDiscordProto::OnMenuDatabaseHistory>);
SET_UID(mi, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x90);
mi.name.a = LPGEN("Enable database history for a guild");
mi.position++;
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_HISTORY);
- m_hMenuDatabaseHistory = Menu_AddContactMenuItem(&mi, m_szModuleName);
-
- HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CDiscordProto::OnMenuPrebuild);
+ g_hMenuDatabaseHistory = Menu_AddContactMenuItem(&mi);
}
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index 5a33a9d6f5..f60174d9a7 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -91,7 +91,8 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) :
// Events
HookProtoEvent(ME_OPT_INITIALISE, &CDiscordProto::OnOptionsInit);
HookProtoEvent(ME_PROTO_ACCLISTCHANGED, &CDiscordProto::OnAccountChanged);
-
+ HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CDiscordProto::OnMenuPrebuild);
+
HookProtoEvent(PE_VOICE_CALL_STATE, &CDiscordProto::OnVoiceState);
// avatars
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index 04fe34110b..d0b7b24117 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -420,8 +420,10 @@ class CDiscordProto : public PROTO<CDiscordProto>
//////////////////////////////////////////////////////////////////////////////////////
// menu items
- void InitMenus(void);
+public:
+ static void InitMenus(void);
+private:
int __cdecl OnMenuPrebuild(WPARAM, LPARAM);
INT_PTR __cdecl OnMenuCopyId(WPARAM, LPARAM);
@@ -432,8 +434,6 @@ class CDiscordProto : public PROTO<CDiscordProto>
INT_PTR __cdecl OnMenuLoadHistory(WPARAM, LPARAM);
INT_PTR __cdecl OnMenuToggleSync(WPARAM, LPARAM);
- HGENMENU m_hMenuLeaveGuild, m_hMenuCreateChannel, m_hMenuToggleSync, m_hMenuDatabaseHistory;
-
//////////////////////////////////////////////////////////////////////////////////////
// guilds
diff --git a/protocols/Discord/src/stdafx.h b/protocols/Discord/src/stdafx.h
index 6e11d96455..b29b751fb7 100644
--- a/protocols/Discord/src/stdafx.h
+++ b/protocols/Discord/src/stdafx.h
@@ -56,6 +56,7 @@
#include "opus/opus.h"
extern IconItem g_iconList[];
+extern HGENMENU g_hMenuLeaveGuild, g_hMenuCreateChannel, g_hMenuToggleSync, g_hMenuDatabaseHistory;
#define DB_KEY_ID "id"
#define DB_KEY_TOKEN "AccessToken"