From c4c1ce437199d554133859c635c3b986f1b353a9 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 4 Mar 2023 18:05:38 +0300 Subject: fixes #3333 (Tox: search in Find/Add contacts tries to search any random input) --- protocols/Tox/src/tox_proto.cpp | 2 +- protocols/Tox/src/tox_proto.h | 6 +++--- protocols/Tox/src/tox_search.cpp | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'protocols/Tox/src') diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 4d29655855..d2e236cbd8 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -134,7 +134,7 @@ int CToxProto::FileResume(HANDLE hTransfer, int action, const wchar_t *szFilenam return OnFileResume(m_tox, hTransfer, action, szFilename); } -HWND CToxProto::SearchAdvanced(HWND owner) +HANDLE CToxProto::SearchAdvanced(HWND owner) { return OnSearchAdvanced(owner); } diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 2a6e485932..944675a71b 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -32,7 +32,7 @@ public: INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override; - HWND SearchAdvanced(HWND owner) override; + HANDLE SearchAdvanced(HWND owner) override; HWND CreateExtendedSearchUI(HWND owner) override; int SendMsg(MCONTACT hContact, int flags, const char *msg) override; @@ -169,8 +169,8 @@ private: static INT_PTR CALLBACK SearchDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - HWND __cdecl OnSearchAdvanced(HWND owner); - HWND __cdecl OnCreateExtendedSearchUI(HWND owner); + HANDLE OnSearchAdvanced(HWND owner); + HWND OnCreateExtendedSearchUI(HWND owner); // messages std::map messages; diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index 0748c0be8f..96f3de2dc6 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -45,10 +45,10 @@ void CToxProto::SearchByNameAsync(void *arg) mir_snprintf(email, "%s@toxme.io", name); psr.email.a = mir_strdup(email); - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr); + ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, this, (LPARAM)&psr); } - ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); + ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, this, 0); mir_free(arg); } @@ -73,7 +73,7 @@ INT_PTR CToxProto::SearchDlgProc(HWND hwnd, UINT uMsg, WPARAM, LPARAM lParam) return FALSE; } -HWND CToxProto::OnSearchAdvanced(HWND owner) +HANDLE CToxProto::OnSearchAdvanced(HWND owner) { if (!IsOnline()) { // we cannot add someone to friend list while tox is offline @@ -93,16 +93,16 @@ HWND CToxProto::OnSearchAdvanced(HWND owner) psr.id.a = mir_strdup(query.c_str()); Contact::AddBySearch(m_szModuleName, &psr, owner); - ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1); + ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, this); } else { regex = "^\\s*(([^ @/:;()\"']+)(@[A-Za-z]+.[A-Za-z]{2,6})?)\\s*$"; if (std::regex_search(query, match, regex)) ForkThread(&CToxProto::SearchByNameAsync, mir_strdup(query.c_str())); else - ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1); + ProtoBroadcastAsync(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, this, (LPARAM)TranslateT("Invalid search string")); } - return (HWND)1; + return (HWND)this; } HWND CToxProto::OnCreateExtendedSearchUI(HWND owner) -- cgit v1.2.3