summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_search.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-09-20 18:57:33 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-09-20 18:57:33 +0000
commit6c21b8918e51b66845f2555c8e3e4dc7d7a3b749 (patch)
tree16465c44f8be467404fbe992754e24dd27bf8f86 /protocols/Tox/src/tox_search.cpp
parent50445999b29be69be5c9eb0e3fe340d317a0b600 (diff)
Tox:
- tox id is string again (h8!!) - updated tox core git-svn-id: http://svn.miranda-ng.org/main/trunk@10537 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, 28 insertions, 14 deletions
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp
index 88726cadb8..6ceea8d07f 100644
--- a/protocols/Tox/src/tox_search.cpp
+++ b/protocols/Tox/src/tox_search.cpp
@@ -6,7 +6,7 @@ void CToxProto::SearchFailedAsync(void*)
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HWND)1, 0);
}
-void CToxProto::SearchByNameAsync(void* arg)
+void CToxProto::SearchByNameAsync(void *arg)
{
char *query = (char*)arg;
char *name = strtok(query, "@");
@@ -45,6 +45,14 @@ void CToxProto::SearchByNameAsync(void* arg)
{
std::string id = DataToHexString(address);
+ if (IsMe(id))
+ {
+ ShowNotification(TranslateT("You cannot add yourself to friend list"), 0);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_FAILED, (HANDLE)1, 0);
+ mir_free(arg);
+ return;
+ }
+
PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) };
psr.flags = PSR_TCHAR;
psr.id = mir_a2t(id.c_str());
@@ -115,23 +123,29 @@ HWND __cdecl CToxProto::SearchAdvanced(HWND owner)
if (std::regex_search(query, match, regex))
{
std::string address = match[1];
- std::vector<uint8_t> id = HexStringToData(address);
- MCONTACT hContact = FindContact(id);
- if (!hContact)
+ if (IsMe(address))
{
- 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);
+ ShowNotification(TranslateT("You cannot add yourself to friend list"), 0);
}
else
{
- ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact);
+ MCONTACT hContact = FindContact(address);
+ if (!hContact)
+ {
+ 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);
+ }
+ else
+ {
+ ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact);
+ }
}
ForkThread(&CToxProto::SearchFailedAsync, NULL);
}