diff options
-rw-r--r-- | protocols/Tox/bin/x64/libtox.dll | bin | 4056175 -> 4055663 bytes | |||
-rw-r--r-- | protocols/Tox/bin/x64/libtox.pdb | bin | 642048 -> 642048 bytes | |||
-rw-r--r-- | protocols/Tox/bin/x86/libtox.dll | bin | 3397231 -> 3396719 bytes | |||
-rw-r--r-- | protocols/Tox/bin/x86/libtox.pdb | bin | 633856 -> 633856 bytes | |||
-rw-r--r-- | protocols/Tox/include/toxencryptsave.h | 8 | ||||
-rw-r--r-- | protocols/Tox/src/api_encryption.cpp | 8 | ||||
-rw-r--r-- | protocols/Tox/src/tox_address.h | 51 | ||||
-rw-r--r-- | protocols/Tox/src/tox_avatars.cpp | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_contacts.cpp | 18 | ||||
-rw-r--r-- | protocols/Tox/src/tox_core.cpp | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_network.cpp | 17 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 15 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_search.cpp | 4 | ||||
-rw-r--r-- | protocols/Tox/src/version.h | 2 |
15 files changed, 75 insertions, 54 deletions
diff --git a/protocols/Tox/bin/x64/libtox.dll b/protocols/Tox/bin/x64/libtox.dll Binary files differindex 3444546b41..3abb8716e9 100644 --- a/protocols/Tox/bin/x64/libtox.dll +++ b/protocols/Tox/bin/x64/libtox.dll diff --git a/protocols/Tox/bin/x64/libtox.pdb b/protocols/Tox/bin/x64/libtox.pdb Binary files differindex 970799a846..4ca669c229 100644 --- a/protocols/Tox/bin/x64/libtox.pdb +++ b/protocols/Tox/bin/x64/libtox.pdb diff --git a/protocols/Tox/bin/x86/libtox.dll b/protocols/Tox/bin/x86/libtox.dll Binary files differindex 7efeda5a74..8d982ecbc7 100644 --- a/protocols/Tox/bin/x86/libtox.dll +++ b/protocols/Tox/bin/x86/libtox.dll diff --git a/protocols/Tox/bin/x86/libtox.pdb b/protocols/Tox/bin/x86/libtox.pdb Binary files differindex 86cce6d985..cb30712975 100644 --- a/protocols/Tox/bin/x86/libtox.pdb +++ b/protocols/Tox/bin/x86/libtox.pdb diff --git a/protocols/Tox/include/toxencryptsave.h b/protocols/Tox/include/toxencryptsave.h index 5c0196d3c6..be6f9b27e2 100644 --- a/protocols/Tox/include/toxencryptsave.h +++ b/protocols/Tox/include/toxencryptsave.h @@ -142,7 +142,7 @@ typedef enum TOX_ERR_DECRYPTION { * * returns true on success */ -bool tox_pass_encrypt(const uint8_t *data, size_t data_len, uint8_t *passphrase, size_t pplength, uint8_t *out, +bool tox_pass_encrypt(const uint8_t *data, size_t data_len, const uint8_t *passphrase, size_t pplength, uint8_t *out, TOX_ERR_ENCRYPTION *error); @@ -154,7 +154,7 @@ bool tox_pass_encrypt(const uint8_t *data, size_t data_len, uint8_t *passphrase, * * returns true on success */ -bool tox_pass_decrypt(const uint8_t *data, size_t length, uint8_t *passphrase, size_t pplength, uint8_t *out, +bool tox_pass_decrypt(const uint8_t *data, size_t length, const uint8_t *passphrase, size_t pplength, uint8_t *out, TOX_ERR_DECRYPTION *error); @@ -182,13 +182,13 @@ typedef struct { * * returns true on success */ -bool tox_derive_key_from_pass(uint8_t *passphrase, size_t pplength, TOX_PASS_KEY *out_key, +bool tox_derive_key_from_pass(const uint8_t *passphrase, size_t pplength, TOX_PASS_KEY *out_key, TOX_ERR_KEY_DERIVATION *error); /* Same as above, except use the given salt for deterministic key derivation. * The salt must be TOX_PASS_SALT_LENGTH bytes in length. */ -bool tox_derive_key_with_salt(uint8_t *passphrase, size_t pplength, uint8_t *salt, TOX_PASS_KEY *out_key, +bool tox_derive_key_with_salt(const uint8_t *passphrase, size_t pplength, const uint8_t *salt, TOX_PASS_KEY *out_key, TOX_ERR_KEY_DERIVATION *error); /* This retrieves the salt used to encrypt the given data, which can then be passed to diff --git a/protocols/Tox/src/api_encryption.cpp b/protocols/Tox/src/api_encryption.cpp index b57e342e99..85e77c06ad 100644 --- a/protocols/Tox/src/api_encryption.cpp +++ b/protocols/Tox/src/api_encryption.cpp @@ -2,14 +2,14 @@ /* ENCRYPTION FUNCTIONS */
-bool tox_pass_decrypt(const uint8_t *data, size_t length, uint8_t *passphrase, size_t pplength, uint8_t *out, TOX_ERR_DECRYPTION *error)
+bool tox_pass_decrypt(const uint8_t *data, size_t length, const uint8_t *passphrase, size_t pplength, uint8_t *out, TOX_ERR_DECRYPTION *error)
{
- return CreateFunction<bool(*)(const uint8_t *, size_t, uint8_t*, size_t, uint8_t*, TOX_ERR_DECRYPTION*)>(__FUNCTION__)(data, length, passphrase, pplength, out, error);
+ return CreateFunction<bool(*)(const uint8_t *, size_t, const uint8_t*, size_t, uint8_t*, TOX_ERR_DECRYPTION*)>(__FUNCTION__)(data, length, passphrase, pplength, out, error);
}
-bool tox_pass_encrypt(const uint8_t *data, size_t data_len, uint8_t *passphrase, size_t pplength, uint8_t *out, TOX_ERR_ENCRYPTION *error)
+bool tox_pass_encrypt(const uint8_t *data, size_t data_len, const uint8_t *passphrase, size_t pplength, uint8_t *out, TOX_ERR_ENCRYPTION *error)
{
- return CreateFunction<bool(*)(const uint8_t *, size_t, uint8_t*, size_t, uint8_t*, TOX_ERR_ENCRYPTION*)>(__FUNCTION__)(data, data_len, passphrase, pplength, out, error);
+ return CreateFunction<bool(*)(const uint8_t *, size_t, const uint8_t*, size_t, uint8_t*, TOX_ERR_ENCRYPTION*)>(__FUNCTION__)(data, data_len, passphrase, pplength, out, error);
}
bool tox_is_data_encrypted(const uint8_t *data)
diff --git a/protocols/Tox/src/tox_address.h b/protocols/Tox/src/tox_address.h index 265ed2f94e..2688118fe2 100644 --- a/protocols/Tox/src/tox_address.h +++ b/protocols/Tox/src/tox_address.h @@ -8,23 +8,36 @@ class ToxHexAddress {
private:
std::string hexData;
+ void Init(const char *hex, size_t size)
+ {
+ hexData = std::string(hex, size);
+ }
+ void Init(const uint8_t *bin, size_t size)
+ {
+ char *hex = (char*)mir_alloc(size * 2 + 1);
+ hexData = bin2hex(bin, size, hex);
+ std::transform(hexData.begin(), hexData.end(), hexData.begin(), ::toupper);
+ mir_free(hex);
+ }
public:
ToxHexAddress(const ToxHexAddress &address) : hexData(address.hexData) { }
ToxHexAddress(const char *hex, size_t size = TOX_ADDRESS_SIZE * 2) : hexData(hex, hex + size) { }
ToxHexAddress(const std::string &hex)
{
- this->ToxHexAddress::ToxHexAddress(hex.c_str(), hex.size());
+ Init(hex.c_str(), hex.size());
}
ToxHexAddress(const uint8_t *bin, size_t size = TOX_ADDRESS_SIZE)
{
- char *hex = (char*)mir_alloc(size * 2 + 1);
- hexData = bin2hex(bin, size, hex);
- std::transform(hexData.begin(), hexData.end(), hexData.begin(), ::toupper);
- mir_free(hex);
+ Init(bin, size);
}
ToxHexAddress(const std::vector<uint8_t> &bin)
{
- this->ToxHexAddress::ToxHexAddress(bin.data(), bin.size());
+ Init(bin.data(), bin.size());
+ }
+ ToxHexAddress& operator=(const char *hex)
+ {
+ Init(hex, mir_strlen(hex));
+ return *this;
}
const size_t GetLength() const
{
@@ -54,24 +67,34 @@ class ToxBinAddress {
private:
std::vector<uint8_t> binData;
-public:
- ToxBinAddress(const ToxBinAddress &address) : binData(address.binData) { }
- ToxBinAddress(const uint8_t *bin, size_t size = TOX_ADDRESS_SIZE) : binData(bin, bin + size) { }
- ToxBinAddress(const std::vector<uint8_t> &bin, size_t size = TOX_ADDRESS_SIZE) : binData(bin.begin(), bin.begin() + size) { }
- ToxBinAddress(const char *hex, size_t size = TOX_ADDRESS_SIZE * 2)
+ void Init(const char *hex, size_t size)
{
char *endptr;
const char *pos = hex;
- for (size_t i = 0; i < size / 2; i++)
+ size /= 2; binData.resize(size);
+ for (size_t i = 0; i < size; i++)
{
char buf[5] = { '0', 'x', pos[0], pos[1], 0 };
- binData.push_back((uint8_t)strtol(buf, &endptr, 0));
+ binData[i] = (uint8_t)strtol(buf, &endptr, 0);
pos += 2;
}
}
+public:
+ ToxBinAddress(const ToxBinAddress &address) : binData(address.binData) { }
+ ToxBinAddress(const uint8_t *bin, size_t size = TOX_ADDRESS_SIZE) : binData(bin, bin + size) { }
+ ToxBinAddress(const std::vector<uint8_t> &bin, size_t size = TOX_ADDRESS_SIZE) : binData(bin.begin(), bin.begin() + size) { }
+ ToxBinAddress(const char *hex, size_t size = TOX_ADDRESS_SIZE * 2)
+ {
+ Init(hex, size);
+ }
ToxBinAddress(const std::string &hex)
{
- this->ToxBinAddress::ToxBinAddress(hex.c_str(), hex.size());
+ Init(hex.c_str(), hex.size());
+ }
+ ToxBinAddress& operator=(const char *hex)
+ {
+ Init(hex, mir_strlen(hex));
+ return *this;
}
const ToxBinAddress GetPubKey() const
{
diff --git a/protocols/Tox/src/tox_avatars.cpp b/protocols/Tox/src/tox_avatars.cpp index 70bd8fd299..30132522ce 100644 --- a/protocols/Tox/src/tox_avatars.cpp +++ b/protocols/Tox/src/tox_avatars.cpp @@ -150,10 +150,12 @@ INT_PTR CToxProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) INT_PTR CToxProto::SetMyAvatar(WPARAM, LPARAM lParam)
{
+ debugLogA("CToxProto::SetMyAvatar: setting avatar");
TCHAR *path = (TCHAR*)lParam;
std::tstring avatarPath = GetAvatarFilePath();
if (path != NULL)
{
+ debugLogA("CToxProto::SetMyAvatar: copy new avatar");
if (!CopyFile(path, avatarPath.c_str(), FALSE))
{
debugLogA("CToxProto::SetMyAvatar: failed to copy new avatar to avatar cache");
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index dfd9159fcc..3ec9c3b1d5 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -87,9 +87,7 @@ MCONTACT CToxProto::AddContact(const char *address, const TCHAR *dnsId, bool isT setByte(hContact, "Grant", 1);
if (isTemporary)
- {
db_set_b(hContact, "CList", "NotOnList", 1);
- }
}
return hContact;
}
@@ -98,7 +96,7 @@ uint32_t CToxProto::GetToxFriendNumber(MCONTACT hContact) {
ToxBinAddress pubKey = ptrA(getStringA(hContact, TOX_SETTINGS_ID));
TOX_ERR_FRIEND_BY_PUBLIC_KEY error;
- uint32_t friendNumber = tox_friend_by_public_key(tox, pubKey, &error);
+ uint32_t friendNumber = tox_friend_by_public_key(tox, pubKey.GetPubKey(), &error);
if (error != TOX_ERR_FRIEND_BY_PUBLIC_KEY_OK)
debugLogA(__FUNCTION__": failed to get friend number (%d)", error);
return friendNumber;
@@ -151,13 +149,11 @@ void CToxProto::LoadFriendList(void*) INT_PTR CToxProto::OnRequestAuth(WPARAM hContact, LPARAM lParam)
{
if (!IsOnline())
- {
- return -1; // ???
- }
+ return 0;
char *reason = lParam ? (char*)lParam : " ";
size_t length = mir_strlen(reason);
- ToxBinAddress address(ptrA(getStringA(hContact, TOX_SETTINGS_ID)));
+ ToxBinAddress address = ptrA(getStringA(hContact, TOX_SETTINGS_ID));
TOX_ERR_FRIEND_ADD addFriendResult;
int32_t friendNumber = tox_friend_add(tox, address, (uint8_t*)reason, length, &addFriendResult);
@@ -185,12 +181,9 @@ INT_PTR CToxProto::OnRequestAuth(WPARAM hContact, LPARAM lParam) INT_PTR CToxProto::OnGrantAuth(WPARAM hContact, LPARAM)
{
if (!IsOnline())
- {
- // TODO: warn
return 0;
- }
- ToxBinAddress pubKey(ptrA(getStringA(hContact, TOX_SETTINGS_ID)));
+ ToxBinAddress pubKey = ptrA(getStringA(hContact, TOX_SETTINGS_ID));
TOX_ERR_FRIEND_ADD error;
tox_friend_add_norequest(tox, pubKey, &error);
if (error != TOX_ERR_FRIEND_ADD_OK)
@@ -226,6 +219,7 @@ int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM) debugLogA(__FUNCTION__": failed to delete friend (%d)", error);
return error;
}
+ SaveToxProfile();
}
/*else
{
@@ -244,7 +238,7 @@ void CToxProto::OnFriendRequest(Tox*, const uint8_t *pubKey, const uint8_t *mess {
CToxProto *proto = (CToxProto*)arg;
- ToxHexAddress address(pubKey, TOX_ADDRESS_SIZE);
+ ToxHexAddress address(pubKey);
MCONTACT hContact = proto->AddContact(address, _T(""));
if (!hContact)
{
diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index 078c16d984..51e7ac70d8 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -72,7 +72,7 @@ bool CToxProto::InitToxCore() uint8_t data[TOX_ADDRESS_SIZE];
tox_self_get_address(tox, data);
- ToxHexAddress address(data, TOX_ADDRESS_SIZE);
+ ToxHexAddress address(data);
setString(TOX_SETTINGS_ID, address);
uint8_t nick[TOX_MAX_NAME_LENGTH] = { 0 };
diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp index 1191568773..860f5c5798 100644 --- a/protocols/Tox/src/tox_network.cpp +++ b/protocols/Tox/src/tox_network.cpp @@ -5,13 +5,16 @@ bool CToxProto::IsOnline() return isConnected && m_iStatus > ID_STATUS_OFFLINE;
}
-void CToxProto::BootstrapNode(const char *address, int port, const uint8_t *pubKey)
+void CToxProto::BootstrapNode(const char *address, int port, const char *hexKey)
{
+ if (hexKey == NULL)
+ return;
+ ToxBinAddress binKey(hexKey, TOX_PUBLIC_KEY_SIZE * 2);
TOX_ERR_BOOTSTRAP error;
- if (!tox_bootstrap(tox, address, port, pubKey, &error))
- {
- debugLogA("CToxProto::BootstrapNode: failed to bootstrap node %s:%d \"%s\" (%d)", address, port, (const char*)ToxHexAddress(pubKey), error);
- }
+ if (!tox_bootstrap(tox, address, port, binKey, &error))
+ debugLogA(__FUNCTION__ ": failed to bootstrap node %s:%d \"%s\" (%d)", address, port, hexKey, error);
+ if (!tox_add_tcp_relay(tox, address, port, binKey, &error))
+ debugLogA(__FUNCTION__ ": failed to add tcp relay%s:%d \"%s\" (%d)", address, port, hexKey, error);
}
void CToxProto::BootstrapNodesFromDb(bool isIPv6)
@@ -29,7 +32,7 @@ void CToxProto::BootstrapNodesFromDb(bool isIPv6) mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PORT, i);
int port = db_get_w(NULL, module, setting, 33445);
mir_snprintf(setting, SIZEOF(setting), TOX_SETTINGS_NODE_PKEY, i);
- ToxBinAddress pubKey(ptrA(db_get_sa(NULL, module, setting)));
+ ptrA pubKey(db_get_sa(NULL, module, setting));
BootstrapNode(address, port, pubKey);
if (isIPv6)
{
@@ -59,7 +62,7 @@ void CToxProto::BootstrapNodesFromIni(bool isIPv6) ptrA address(mir_strdup(value));
int port = GetPrivateProfileIntA(section, "Port", 33445, fileName);
GetPrivateProfileStringA(section, "PubKey", NULL, value, SIZEOF(value), fileName);
- ToxBinAddress pubKey(value);
+ ptrA pubKey(mir_strdup(value));
BootstrapNode(address, port, pubKey);
if (isIPv6)
{
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 3891400c79..0e7d157c45 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -1,10 +1,10 @@ #include "stdafx.h"
CToxProto::CToxProto(const char* protoName, const TCHAR* userName) :
- PROTO<CToxProto>(protoName, userName),
- tox(NULL), toxAv(NULL), password(NULL),
- isTerminated(false), isConnected(false),
- hPollingThread(NULL), hOutDevice(NULL)
+PROTO<CToxProto>(protoName, userName),
+tox(NULL), toxAv(NULL), password(NULL),
+isTerminated(false), isConnected(false),
+hPollingThread(NULL), hOutDevice(NULL)
{
InitNetlib();
@@ -70,14 +70,13 @@ MCONTACT CToxProto::AddToList(int flags, PROTOSEARCHRESULT *psr) ShowNotification(TranslateT("You cannot add yourself to your contact list"), 0);
return NULL;
}
- MCONTACT hContact = GetContact((char*)address);
- if (hContact)
+ if (MCONTACT hContact = GetContact((char*)address))
{
ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact);
return NULL;
}
- // set tox address as contact public key
- return AddContact(address, _T(""), flags & PALF_TEMPORARY);
+ ptrT dnsId(mir_tstrdup(psr->email));
+ return AddContact(address, dnsId, flags & PALF_TEMPORARY);
}
int CToxProto::Authorize(MEVENT hDbEvent)
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index f532d4f5c1..65f465d485 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -96,7 +96,7 @@ private: // tox network
bool IsOnline();
- void BootstrapNode(const char *address, int port, const uint8_t *pubKey);
+ void BootstrapNode(const char *address, int port, const char *pubKey);
void BootstrapNodesFromDb(bool isIPv6);
void BootstrapNodesFromIni(bool isIPv6);
void BootstrapNodes();
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index c9962d90a0..7b57f54eb0 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -51,7 +51,7 @@ void CToxProto::SearchByNameAsync(void *arg) char fileName[MAX_PATH];
mir_strcpy(fileName, VARS(TOX_INI_PATH));
- char *section, sections[MAX_PATH], value[MAX_PATH];
+ char *section, sections[MAX_PATH], value[TOX_PUBLIC_KEY_SIZE * 2];
GetPrivateProfileSectionNamesA(sections, SIZEOF(sections), fileName);
section = sections;
while (*section != NULL)
@@ -61,7 +61,7 @@ void CToxProto::SearchByNameAsync(void *arg) GetPrivateProfileStringA(section, "Domain", NULL, value, SIZEOF(value), fileName);
ptrA dnsDomain(mir_strdup(value));
GetPrivateProfileStringA(section, "PubKey", NULL, value, SIZEOF(value), fileName);
- ToxBinAddress dnsPubKey(value);
+ ToxBinAddress dnsPubKey = value;
if (domain == NULL || mir_strcmpi(domain, dnsDomain) == 0)
{
diff --git a/protocols/Tox/src/version.h b/protocols/Tox/src/version.h index 0d7396ac76..7203760d6b 100644 --- a/protocols/Tox/src/version.h +++ b/protocols/Tox/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 1
-#define __BUILD_NUM 6
+#define __BUILD_NUM 7
#include <stdver.h>
|