diff options
author | George Hazan <ghazan@miranda.im> | 2020-12-06 15:35:29 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-12-06 15:35:29 +0300 |
commit | fa3d7e46f262cdbfea89b2b9ddab75768024be10 (patch) | |
tree | 06a6fadca2f732bb15ae2eeab1bc69d834fb7aba /protocols/Discord/src | |
parent | 0380841eece1c03a7a47da463c0f94d7945227d9 (diff) |
minor code cleaning + warning fix
Diffstat (limited to 'protocols/Discord/src')
-rw-r--r-- | protocols/Discord/src/groupchat.cpp | 2 | ||||
-rw-r--r-- | protocols/Discord/src/menus.cpp | 14 | ||||
-rw-r--r-- | protocols/Discord/src/utils.cpp | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/protocols/Discord/src/groupchat.cpp b/protocols/Discord/src/groupchat.cpp index ee00b1054e..fffad8683b 100644 --- a/protocols/Discord/src/groupchat.cpp +++ b/protocols/Discord/src/groupchat.cpp @@ -81,7 +81,7 @@ void CDiscordProto::Chat_SendPrivateMessage(GCHOOK *gch) setId(hContact, DB_KEY_ID, userId); setId(hContact, DB_KEY_CHANNELID, _wtoi64(gch->si->ptszID)); - setWString(hContact, "Nick", gch->ptszNick); + setWString(hContact, DB_KEY_NICK, gch->ptszNick); Contact_Hide(hContact); db_set_dw(hContact, "Ignore", "Mask1", 0); } diff --git a/protocols/Discord/src/menus.cpp b/protocols/Discord/src/menus.cpp index 3cc43fc6ab..59dcc683a5 100644 --- a/protocols/Discord/src/menus.cpp +++ b/protocols/Discord/src/menus.cpp @@ -19,16 +19,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. 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(); + + CMStringW mynick(FORMAT, L"%s#%d", getMStringW(hContact, DB_KEY_NICK).c_str(), getDword(hContact, DB_KEY_DISCR)); 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); + if (HGLOBAL hMemory = GlobalAlloc(GMEM_FIXED, length * sizeof(wchar_t))) { + mir_wstrncpy((wchar_t *)GlobalLock(hMemory), mynick, length); + GlobalUnlock(hMemory); + SetClipboardData(CF_UNICODETEXT, hMemory); + } CloseClipboard(); } diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp index eac8d02a2b..5c4da0c370 100644 --- a/protocols/Discord/src/utils.cpp +++ b/protocols/Discord/src/utils.cpp @@ -349,7 +349,7 @@ void CDiscordProto::ParseSpecialChars(SESSION_INFO *si, CMStringW &str) else if (wszWord[0] == '#') { CDiscordUser *pUser = FindUserByChannel(_wtoi64(wszWord.c_str() + 1)); if (pUser != nullptr) { - ptrW wszNick(getWStringA(pUser->hContact, "Nick")); + ptrW wszNick(getWStringA(pUser->hContact, DB_KEY_NICK)); if (wszNick != nullptr) str.Replace(L"<" + wszWord + L">", wszNick); } |