diff options
author | George Hazan <ghazan@miranda.im> | 2019-03-06 20:34:51 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-03-06 20:34:51 +0300 |
commit | e855b0922f15871e8deb07562f3d5c8ba675bf93 (patch) | |
tree | 1f0dc19f024964595c1c53d1d8ef3d33cdd6c47f /protocols/Discord/src/menus.cpp | |
parent | 85a007ed346d57d266dca3f6c6b2809ca8d61c97 (diff) |
related to #1863 ([Discord] Make option to turn off group chats/channels ; & add manual history sync from IMs/DMs (private chat))
Diffstat (limited to 'protocols/Discord/src/menus.cpp')
-rw-r--r-- | protocols/Discord/src/menus.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/protocols/Discord/src/menus.cpp b/protocols/Discord/src/menus.cpp index a465dbb33c..88404bd782 100644 --- a/protocols/Discord/src/menus.cpp +++ b/protocols/Discord/src/menus.cpp @@ -76,15 +76,33 @@ INT_PTR CDiscordProto::OnMenuLeaveGuild(WPARAM hContact, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// +INT_PTR CDiscordProto::OnMenuToggleSync(WPARAM hContact, LPARAM) +{ + bool bEnabled = !getBool(hContact, "EnableSync"); + setByte(hContact, "EnableSync", bEnabled); + + if (bEnabled) + GatewaySendGuildInfo(getId(hContact, DB_KEY_CHANNELID)); + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + 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); if (getWord(hContact, "ApparentMode") != 0) Menu_ShowItem(m_hmiReqAuth, true); + + if (getByte(hContact, "EnableSync")) + Menu_ModifyItem(m_hMenuToggleSync, LPGENW("Disable sync"), Skin_GetIconHandle(SKINICON_CHAT_LEAVE)); + else + Menu_ModifyItem(m_hMenuToggleSync, LPGENW("Enable sync"), Skin_GetIconHandle(SKINICON_CHAT_JOIN)); return 0; } @@ -136,5 +154,13 @@ void CDiscordProto::InitMenus() SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8E); Menu_AddContactMenuItem(&mi2, m_szModuleName); + mi2.pszService = "/ToggleSync"; + CreateProtoService(mi2.pszService, &CDiscordProto::OnMenuToggleSync); + mi2.name.a = LPGEN("Enable guild"); + mi2.position = -200001003; + mi2.hIcolibItem = Skin_GetIconHandle(SKINICON_CHAT_JOIN); + SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8F); + m_hMenuToggleSync = Menu_AddContactMenuItem(&mi2, m_szModuleName); + HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CDiscordProto::OnMenuPrebuild); } |