From 6524ac4e637dba2de42df5ca6eac4a9a5501a4d2 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 27 Apr 2016 12:44:53 +0000 Subject: Tox: - attempt to fix avatar hash - some changes with toxThread git-svn-id: http://svn.miranda-ng.org/main/trunk@16773 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_core.cpp | 73 +++++++++++++++++++++++------------------- 1 file changed, 40 insertions(+), 33 deletions(-) (limited to 'protocols/Tox/src/tox_core.cpp') diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index f37ec8d866..9910f8cc1f 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -38,7 +38,14 @@ Tox_Options* CToxProto::GetToxOptions() } } - return options; + if (LoadToxProfile(options)) + { + return options; + } + + tox_options_free(options); + + return NULL; } bool CToxProto::InitToxCore(CToxThread *toxThread) @@ -48,72 +55,72 @@ bool CToxProto::InitToxCore(CToxThread *toxThread) if (toxThread == NULL) return false; - Tox_Options *options = GetToxOptions(); + /*Tox_Options *options = GetToxOptions(); if (options == NULL) return false; if (LoadToxProfile(options)) { TOX_ERR_NEW initError; - toxThread->tox = tox_new(options, &initError); + toxThread->Tox() = tox_new(options, &initError); if (initError != TOX_ERR_NEW_OK) { logger->Log(__FUNCTION__": failed to initialize tox core (%d)", initError); ShowNotification(ToxErrorToString(initError), TranslateT("Unable to initialize Tox core"), MB_ICONERROR); tox_options_free(options); return false; - } + }*/ - tox_callback_friend_request(toxThread->tox, OnFriendRequest, this); - tox_callback_friend_message(toxThread->tox, OnFriendMessage, this); - tox_callback_friend_read_receipt(toxThread->tox, OnReadReceipt, this); - tox_callback_friend_typing(toxThread->tox, OnTypingChanged, this); + tox_callback_friend_request(toxThread->Tox(), OnFriendRequest, this); + tox_callback_friend_message(toxThread->Tox(), OnFriendMessage, this); + tox_callback_friend_read_receipt(toxThread->Tox(), OnReadReceipt, this); + tox_callback_friend_typing(toxThread->Tox(), OnTypingChanged, this); // - tox_callback_friend_name(toxThread->tox, OnFriendNameChange, this); - tox_callback_friend_status_message(toxThread->tox, OnStatusMessageChanged, this); - tox_callback_friend_status(toxThread->tox, OnUserStatusChanged, this); - tox_callback_friend_connection_status(toxThread->tox, OnConnectionStatusChanged, this); + tox_callback_friend_name(toxThread->Tox(), OnFriendNameChange, this); + tox_callback_friend_status_message(toxThread->Tox(), OnStatusMessageChanged, this); + tox_callback_friend_status(toxThread->Tox(), OnUserStatusChanged, this); + tox_callback_friend_connection_status(toxThread->Tox(), OnConnectionStatusChanged, this); // transfers - tox_callback_file_recv_control(toxThread->tox, OnFileRequest, this); - tox_callback_file_recv(toxThread->tox, OnFriendFile, this); - tox_callback_file_recv_chunk(toxThread->tox, OnDataReceiving, this); - tox_callback_file_chunk_request(toxThread->tox, OnFileSendData, this); + tox_callback_file_recv_control(toxThread->Tox(), OnFileRequest, this); + tox_callback_file_recv(toxThread->Tox(), OnFriendFile, this); + tox_callback_file_recv_chunk(toxThread->Tox(), OnDataReceiving, this); + tox_callback_file_chunk_request(toxThread->Tox(), OnFileSendData, this); // group chats //tox_callback_group_invite(tox, OnGroupChatInvite, this); // a/v //if (IsWinVerVistaPlus()) //{ // TOXAV_ERR_NEW avInitError; - // toxThread->toxAV = toxav_new(toxThread->tox, &avInitError); + // toxThread->Tox()AV = toxav_new(toxThread->Tox(), &avInitError); // if (initError != TOX_ERR_NEW_OK) // { - // toxav_callback_call(toxThread->toxAV, OnFriendCall, this); - // toxav_callback_call_state(toxThread->toxAV, OnFriendCallState, this); - // toxav_callback_bit_rate_status(toxThread->toxAV, OnBitrateChanged, this); - // toxav_callback_audio_receive_frame(toxThread->toxAV, OnFriendAudioFrame, this); - // //toxav_callback_video_receive_frame(toxThread->toxAV, , this); + // toxav_callback_call(toxThread->Tox()AV, OnFriendCall, this); + // toxav_callback_call_state(toxThread->Tox()AV, OnFriendCallState, this); + // toxav_callback_bit_rate_status(toxThread->Tox()AV, OnBitrateChanged, this); + // toxav_callback_audio_receive_frame(toxThread->Tox()AV, OnFriendAudioFrame, this); + // //toxav_callback_video_receive_frame(toxThread->Tox()AV, , this); // } //} uint8_t data[TOX_ADDRESS_SIZE]; - tox_self_get_address(toxThread->tox, data); + tox_self_get_address(toxThread->Tox(), data); ToxHexAddress address(data); setString(TOX_SETTINGS_ID, address); uint8_t nick[TOX_MAX_NAME_LENGTH] = { 0 }; - tox_self_get_name(toxThread->tox, nick); + tox_self_get_name(toxThread->Tox(), nick); setTString("Nick", ptrT(Utf8DecodeT((char*)nick))); uint8_t statusMessage[TOX_MAX_STATUS_MESSAGE_LENGTH] = { 0 }; - tox_self_get_status_message(toxThread->tox, statusMessage); + tox_self_get_status_message(toxThread->Tox(), statusMessage); setTString("StatusMsg", ptrT(Utf8DecodeT((char*)statusMessage))); return true; - } + /*} tox_options_free(options); - return false; + return false;*/ } void CToxProto::UninitToxCore(CToxThread *toxThread) @@ -121,15 +128,15 @@ void CToxProto::UninitToxCore(CToxThread *toxThread) if (toxThread == NULL) return; - if (toxThread->toxAV) - toxav_kill(toxThread->toxAV); + /*if (toxThread->ToxAV()) + toxav_kill(toxThread->ToxAV()); - if (toxThread->tox == NULL) - return; + if (toxThread->Tox() == NULL) + return;*/ CancelAllTransfers(); SaveToxProfile(toxThread); - tox_kill(toxThread->tox); - toxThread->tox = NULL; + //tox_kill(toxThread->Tox()); + //toxThread->Tox() = NULL; } \ No newline at end of file -- cgit v1.2.3