From 09fa77d73829e76123ac7a9b73bc90def12e9d9c Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 1 Feb 2015 09:23:58 +0000 Subject: Tox: - refactoring - updated tox core git-svn-id: http://svn.miranda-ng.org/main/trunk@11970 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_account.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'protocols/Tox/src/tox_account.cpp') diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp index 3b4f61b32b..2aa3081442 100644 --- a/protocols/Tox/src/tox_account.cpp +++ b/protocols/Tox/src/tox_account.cpp @@ -84,15 +84,14 @@ bool CToxProto::InitToxCore() tox_callback_avatar_info(tox, OnGotFriendAvatarInfo, this); tox_callback_avatar_data(tox, OnGotFriendAvatarData, this); - std::vector pubKey(TOX_FRIEND_ADDRESS_SIZE); - tox_get_address(tox, &pubKey[0]); - std::string address = DataToHexString(pubKey); - setString(NULL, TOX_SETTINGS_ID, address.c_str()); + uint8_t data[TOX_FRIEND_ADDRESS_SIZE]; + tox_get_address(tox, data); + ToxHexAddress address(data, TOX_FRIEND_ADDRESS_SIZE); + setString(NULL, TOX_SETTINGS_ID, address); int size = tox_get_self_name_size(tox); - std::vector username(size); - tox_get_self_name(tox, &username[0]); - std::string nick(username.begin(), username.end()); + std::string nick(size, 0); + tox_get_self_name(tox, (uint8_t*)nick.data()); setWString("Nick", ptrW(Utf8DecodeW(nick.c_str()))); std::tstring avatarPath = GetAvatarFilePath(); @@ -117,7 +116,7 @@ bool CToxProto::InitToxCore() void CToxProto::UninitToxCore() { ptrA nickname(mir_utf8encodeW(ptrT(getTStringA("Nick")))); - tox_set_name(tox, (uint8_t*)(char*)nickname, (uint16_t)strlen(nickname)); + tox_set_name(tox, (uint8_t*)(char*)nickname, mir_strlen(nickname)); SaveToxProfile(); if (password != NULL) @@ -143,8 +142,6 @@ void CToxProto::DoBootstrap() void CToxProto::DoTox() { tox_do(tox); - - //PulseEvent(hToxEvent); uint32_t interval = tox_do_interval(tox); Sleep(interval); } @@ -178,7 +175,7 @@ void CToxProto::PollingThread(void*) isConnected = true; debugLogA("CToxProto::PollingThread: successfuly connected to DHT"); - LoadFriendList(); + ForkThread(&CToxProto::LoadFriendList, NULL); debugLogA("CToxProto::PollingThread: changing status from %i to %i", ID_STATUS_CONNECTING, m_iDesiredStatus); m_iStatus = m_iDesiredStatus; -- cgit v1.2.3