From 03fec7536e1a86a3f05246e177d09e10f2e982c3 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 2 Oct 2014 18:43:11 +0000 Subject: Tox: dns name saved as id after search git-svn-id: http://svn.miranda-ng.org/main/trunk@10669 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_contacts.cpp | 23 ++++++++++++++++++----- protocols/Tox/src/tox_proto.cpp | 8 ++++---- protocols/Tox/src/tox_proto.h | 2 +- 3 files changed, 23 insertions(+), 10 deletions(-) (limited to 'protocols/Tox/src') diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index b23c4341f9..c474b0a89a 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -92,7 +92,7 @@ MCONTACT CToxProto::FindContact(const int friendNumber) return FindContact(id); } -MCONTACT CToxProto::AddContact(const std::string &id, bool isTemporary) +MCONTACT CToxProto::AddContact(const std::string &id, const std::tstring &dnsId, bool isTemporary) { MCONTACT hContact = FindContact(id); if (!hContact) @@ -101,7 +101,10 @@ MCONTACT CToxProto::AddContact(const std::string &id, bool isTemporary) CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName); setString(hContact, TOX_SETTINGS_ID, id.c_str()); - //setByte(hContact, "Auth", 1); + if (!dnsId.empty()) + { + setTString(hContact, TOX_SETTINGS_DNS, dnsId.c_str()); + } DBVARIANT dbv; if (!getTString(TOX_SETTINGS_GROUP, &dbv)) @@ -110,6 +113,9 @@ MCONTACT CToxProto::AddContact(const std::string &id, bool isTemporary) db_free(&dbv); } + setByte(hContact, "Auth", 1); + setByte(hContact, "Grant", 1); + if (isTemporary) { db_set_b(hContact, "CList", "NotOnList", 1); @@ -130,9 +136,12 @@ void CToxProto::LoadFriendList() for (uint32_t i = 0; i < count; ++i) { tox_get_client_id(tox, friends[i], id.data()); - MCONTACT hContact = AddContact(DataToHexString(id)); + MCONTACT hContact = AddContact(DataToHexString(id), _T("")); if (hContact) { + delSetting(hContact, "Auth"); + delSetting(hContact, "Grant"); + int size = tox_get_name_size(tox, friends[i]); std::vector username(size); tox_get_name(tox, friends[i], &username[0]); @@ -179,13 +188,13 @@ void CToxProto::OnFriendRequest(Tox *tox, const uint8_t *address, const uint8_t std::vector clientId(address, address + TOX_CLIENT_ID_SIZE); std::string id = proto->DataToHexString(clientId); - MCONTACT hContact = proto->AddContact(id); + MCONTACT hContact = proto->AddContact(id, _T("")); if (!hContact) { return; } - proto->setByte(hContact, "Auth", 1); + proto->delSetting(hContact, "Auth"); PROTORECVEVENT pre = { 0 }; pre.flags = PREF_UTF; @@ -254,5 +263,9 @@ void CToxProto::OnConnectionStatusChanged(Tox *tox, const int number, const uint { int newStatus = status ? ID_STATUS_ONLINE : ID_STATUS_OFFLINE; proto->SetContactStatus(hContact, newStatus); + if (status) + { + proto->delSetting(hContact, "Auth"); + } } } \ No newline at end of file diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 54814135c9..c8e350b46e 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -85,7 +85,7 @@ MCONTACT __cdecl CToxProto::AddToList(int flags, PROTOSEARCHRESULT* psr) return NULL; } // set tox address as contact id - return AddContact(address, flags & PALF_TEMPORARY); + return AddContact(address, psr->email, flags & PALF_TEMPORARY); } MCONTACT __cdecl CToxProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent) @@ -109,7 +109,7 @@ int __cdecl CToxProto::Authorize(HANDLE hDbEvent) } db_unset(hContact, "CList", "NotOnList"); - delSetting(hContact, "Auth"); + delSetting(hContact, "Grant"); SaveToxProfile(); return 0; @@ -122,7 +122,7 @@ int __cdecl CToxProto::AuthRecv(MCONTACT, PROTORECVEVENT* pre) return Proto_AuthRecv(m_szModuleName, pre); } -int __cdecl CToxProto::AuthRequest(MCONTACT hContact, const PROTOCHAR* szMessage) +int __cdecl CToxProto::AuthRequest(MCONTACT hContact, const PROTOCHAR *szMessage) { ptrA reason(mir_utf8encodeW(szMessage)); @@ -138,7 +138,7 @@ int __cdecl CToxProto::AuthRequest(MCONTACT hContact, const PROTOCHAR* szMessage setString(hContact, TOX_SETTINGS_ID, id.c_str()); db_unset(hContact, "CList", "NotOnList"); - delSetting(hContact, "Auth"); + delSetting(hContact, "Grant"); std::string nick("", TOX_MAX_NAME_LENGTH); tox_get_name(tox, number, (uint8_t*)&nick[0]); diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 547954bea9..901344a933 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -163,7 +163,7 @@ private: bool IsMe(const std::string &id); MCONTACT FindContact(const std::string &id); MCONTACT FindContact(const int friendNumber); - MCONTACT AddContact(const std::string &id, bool isTemporary = false); + MCONTACT AddContact(const std::string &id, const std::tstring &dnsId, bool isTemporary = false); MCONTACT GetContactFromAuthEvent(HANDLE hEvent); -- cgit v1.2.3