diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-09-20 18:57:33 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-09-20 18:57:33 +0000 |
commit | 6c21b8918e51b66845f2555c8e3e4dc7d7a3b749 (patch) | |
tree | 16465c44f8be467404fbe992754e24dd27bf8f86 /protocols/Tox/src/tox_proto.cpp | |
parent | 50445999b29be69be5c9eb0e3fe340d317a0b600 (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_proto.cpp')
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index ab2cfe61a7..081192322d 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -71,20 +71,14 @@ DWORD_PTR __cdecl CToxProto::GetCaps(int type, MCONTACT hContact) MCONTACT __cdecl CToxProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
- DBVARIANT dbv;
std::string address(mir_t2a(psr->id));
- std::vector<uint8_t> id = HexStringToData(address);
- if (!db_get(NULL, m_szModuleName, TOX_SETTINGS_ID, &dbv))
+ if (IsMe(address))
{
- if (memcmp(id.data(), dbv.pbVal, TOX_CLIENT_ID_SIZE) == 0)
- {
- debugLogA("CToxProto::AddToList: you cannot add yourself to friend list");
- return NULL;
- }
- db_free(&dbv);
+ debugLogA("CToxProto::AddToList: you cannot add yourself to friend list");
+ return NULL;
}
// set tox address as contact id
- return AddContact(id, flags & PALF_TEMPORARY);
+ return AddContact(address, flags & PALF_TEMPORARY);
}
MCONTACT __cdecl CToxProto::AddToListByEvent(int flags, int iContact, HANDLE hDbEvent)
@@ -100,23 +94,18 @@ int __cdecl CToxProto::Authorize(HANDLE hDbEvent) return 1;
}
- DBVARIANT dbv;
- if (!db_get(hContact, m_szModuleName, TOX_SETTINGS_ID, &dbv))
+ std::string id = getStringA(hContact, TOX_SETTINGS_ID);
+ std::vector<uint8_t> clientId = HexStringToData(id);
+ if (tox_add_friend_norequest(tox, clientId.data()) != TOX_ERROR)
{
- std::vector<uint8_t> id(TOX_CLIENT_ID_SIZE);
- memcpy(&id[0], dbv.pbVal, TOX_CLIENT_ID_SIZE);
- if (tox_add_friend_norequest(tox, id.data()) != TOX_ERROR)
- {
- db_unset(hContact, "CList", "NotOnList");
- delSetting(hContact, "Auth");
- SaveToxData();
- db_free(&dbv);
- return 0;
- }
- db_free(&dbv);
+ return 1;
}
- return 1;
+ db_unset(hContact, "CList", "NotOnList");
+ delSetting(hContact, "Auth");
+ SaveToxData();
+
+ return 0;
}
int __cdecl CToxProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason) { return 0; }
@@ -124,28 +113,22 @@ int __cdecl CToxProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason) { re int __cdecl CToxProto::AuthRecv(MCONTACT, PROTORECVEVENT* pre)
{
return Proto_AuthRecv(m_szModuleName, pre);
- // return 0;
}
int __cdecl CToxProto::AuthRequest(MCONTACT hContact, const PROTOCHAR* szMessage)
{
- DBVARIANT dbv;
- std::vector<uint8_t> address(TOX_FRIEND_ADDRESS_SIZE);
- if (!db_get(hContact, m_szModuleName, TOX_SETTINGS_ID, &dbv))
- {
- memcpy(&address[0], (uint8_t*)dbv.pbVal, TOX_FRIEND_ADDRESS_SIZE);
- db_free(&dbv);
- }
-
ptrA reason(mir_utf8encodeW(szMessage));
- int32_t number = tox_add_friend(tox, address.data(), (uint8_t*)(char*)reason, (uint16_t)strlen(reason));
+ std::string id = getStringA(hContact, TOX_SETTINGS_ID);
+ std::vector<uint8_t> pubKey = HexStringToData(id);
+ int32_t number = tox_add_friend(tox, pubKey.data(), (uint8_t*)(char*)reason, (uint16_t)strlen(reason));
if (number > TOX_ERROR)
{
SaveToxData();
// change tox address in contact id by tox id
- db_set_blob(hContact, m_szModuleName, TOX_SETTINGS_ID, (uint8_t*)address.data(), TOX_CLIENT_ID_SIZE);
+ id.resize(TOX_CLIENT_ID_SIZE);
+ setString(hContact, TOX_SETTINGS_ID, id.c_str());
db_unset(hContact, "CList", "NotOnList");
delSetting(hContact, "Auth");
|