summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_search.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-02-01 09:23:58 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-02-01 09:23:58 +0000
commit09fa77d73829e76123ac7a9b73bc90def12e9d9c (patch)
tree20c5e5a4fc83c672e0505db662e88c16635c5d9d /protocols/Tox/src/tox_search.cpp
parenta76b0175b2cb203f4a0cc68c99588f23ef945eb6 (diff)
Tox:
- refactoring - updated tox core git-svn-id: http://svn.miranda-ng.org/main/trunk@11970 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_search.cpp')
-rw-r--r--protocols/Tox/src/tox_search.cpp42
1 files changed, 15 insertions, 27 deletions
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp
index 8e1df68786..d62eccd593 100644
--- a/protocols/Tox/src/tox_search.cpp
+++ b/protocols/Tox/src/tox_search.cpp
@@ -23,7 +23,7 @@ void CToxProto::SearchByNameAsync(void *arg)
uint8_t dnsString[256];
uint32_t requestId = 0;
- int length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)name, strlen(name));
+ int length = tox_generate_dns3_string(dns, dnsString, sizeof(dnsString), &requestId, (uint8_t*)name, mir_strlen(name));
if (length != TOX_ERROR)
{
dnsString[length] = 0;
@@ -40,14 +40,14 @@ void CToxProto::SearchByNameAsync(void *arg)
if (record->wType == DNS_TYPE_TEXT && txt->dwStringCount)
{
char *recordId = &txt->pStringArray[0][10];
- std::vector<uint8_t> address(TOX_FRIEND_ADDRESS_SIZE);
- if (tox_decrypt_dns3_TXT(dns, &address[0], (uint8_t*)recordId, strlen(recordId), requestId) != TOX_ERROR)
+ uint8_t data[TOX_FRIEND_ADDRESS_SIZE];
+ if (tox_decrypt_dns3_TXT(dns, data, (uint8_t*)recordId, mir_strlen(recordId), requestId) != TOX_ERROR)
{
- std::string id = DataToHexString(address);
+ ToxHexAddress address(data, TOX_FRIEND_ADDRESS_SIZE);
PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) };
psr.flags = PSR_TCHAR;
- psr.id = mir_a2t(id.c_str());
+ psr.id = mir_a2t(address);
psr.nick = mir_utf8decodeT(name);
TCHAR email[MAX_PATH];
@@ -115,30 +115,18 @@ HWND __cdecl CToxProto::SearchAdvanced(HWND owner)
if (std::regex_search(query, match, regex))
{
std::string address = match[1];
- if (IsMe(address))
- {
- ShowNotification(TranslateT("You cannot add yourself to friend list"), 0);
- }
- else
- {
- MCONTACT hContact = FindContact(address);
- if (!hContact)
- {
- PROTOSEARCHRESULT psr = { sizeof(psr) };
- psr.flags = PSR_TCHAR;
- psr.id = mir_a2t(query.c_str());
+ MCONTACT hContact = GetContact(address.c_str());
- ADDCONTACTSTRUCT acs = { HANDLE_SEARCHRESULT };
- acs.szProto = m_szModuleName;
- acs.psr = &psr;
+ PROTOSEARCHRESULT psr = { sizeof(psr) };
+ psr.flags = PSR_TCHAR;
+ psr.id = mir_a2t(query.c_str());
+
+ ADDCONTACTSTRUCT acs = { HANDLE_SEARCHRESULT };
+ acs.szProto = m_szModuleName;
+ acs.psr = &psr;
+
+ CallService(MS_ADDCONTACT_SHOW, (WPARAM)owner, (LPARAM)&acs);
- CallService(MS_ADDCONTACT_SHOW, (WPARAM)owner, (LPARAM)&acs);
- }
- else
- {
- ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact);
- }
- }
ForkThread(&CToxProto::SearchFailedAsync, NULL);
}
else