diff options
author | George Hazan <ghazan@miranda.im> | 2017-09-22 14:52:19 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-09-22 14:52:19 +0300 |
commit | 10530cc3c20e0421a4031495b4fa5b474596cea1 (patch) | |
tree | 4871d766763de6e9b67dc4ad6b8fc1d3f75f3272 /protocols/Discord/src | |
parent | a70690cd406a7c5a34a5e589bb55cb2400be618e (diff) |
fixes #937 (Ability to copy my own Discord ID and contacts ID)
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r-- | protocols/Discord/src/menus.cpp | 34 | ||||
-rw-r--r-- | protocols/Discord/src/proto.h | 1 |
2 files changed, 35 insertions, 0 deletions
diff --git a/protocols/Discord/src/menus.cpp b/protocols/Discord/src/menus.cpp index 33d061a7df..5321e06ea2 100644 --- a/protocols/Discord/src/menus.cpp +++ b/protocols/Discord/src/menus.cpp @@ -17,6 +17,26 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "stdafx.h" +INT_PTR CDiscordProto::OnMenuCopyId(WPARAM hContact, LPARAM) +{ + CMStringW mynick(ptrW(getWStringA(hContact, DB_KEY_NICK))); + mynick.AppendFormat(L"#%d", getDword(hContact, DB_KEY_DISCR)); + + if (OpenClipboard(nullptr)) { + EmptyClipboard(); + int length = mynick.GetLength() + 1; + HGLOBAL hMemory = GlobalAlloc(GMEM_FIXED, length * sizeof(wchar_t)); + mir_wstrncpy((wchar_t*)GlobalLock(hMemory), mynick, length); + GlobalUnlock(hMemory); + SetClipboardData(CF_UNICODETEXT, hMemory); + CloseClipboard(); + } + + return 0; +} + +///////////////////////////////////////////////////////////////////////////////////////// + INT_PTR CDiscordProto::OnMenuCreateChannel(WPARAM hContact, LPARAM) { ENTER_STRING es = { sizeof(es), ESF_COMBO, m_szModuleName, "channel_name", TranslateT("Enter channel name"), 0, 5 }; @@ -81,6 +101,13 @@ void CDiscordProto::InitMenus() mi.hIcolibItem = g_iconList[1].hIcolib; Menu_AddProtoMenuItem(&mi, m_szModuleName); + mi.pszService = "/CopyId"; + CreateProtoService(mi.pszService, &CDiscordProto::OnMenuCopyId); + mi.name.a = LPGEN("Copy my Discord id"); + mi.position = 200002; + mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_USERONLINE); + Menu_AddProtoMenuItem(&mi, m_szModuleName); + // Contact menu items CMenuItem mi2; mi2.pszService = "/LeaveGuild"; @@ -99,5 +126,12 @@ void CDiscordProto::InitMenus() SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8D); m_hMenuCreateChannel = Menu_AddContactMenuItem(&mi2, m_szModuleName); + mi2.pszService = "/CopyId"; + mi2.name.a = LPGEN("Copy Discord id"); + mi2.position = -200001002; + mi2.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_USERONLINE); + SET_UID(mi2, 0x6EF11AD6, 0x6111, 0x4E29, 0xBA, 0x8B, 0xA7, 0xB2, 0xE0, 0x22, 0xE1, 0x8E); + Menu_AddContactMenuItem(&mi2, m_szModuleName); + HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CDiscordProto::OnMenuPrebuild); } diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h index e052023d31..b2d18e4350 100644 --- a/protocols/Discord/src/proto.h +++ b/protocols/Discord/src/proto.h @@ -259,6 +259,7 @@ class CDiscordProto : public PROTO<CDiscordProto> int __cdecl OnMenuPrebuild(WPARAM, LPARAM); + INT_PTR __cdecl OnMenuCopyId(WPARAM, LPARAM); INT_PTR __cdecl OnMenuCreateChannel(WPARAM, LPARAM); INT_PTR __cdecl OnMenuJoinGuild(WPARAM, LPARAM); INT_PTR __cdecl OnMenuLeaveGuild(WPARAM, LPARAM); |