diff options
Diffstat (limited to 'protocols/Tox/src/tox_core.cpp')
-rw-r--r-- | protocols/Tox/src/tox_core.cpp | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index d18885fc9b..c040fa3426 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -48,27 +48,24 @@ Tox_Options* CToxProto::GetToxOptions() return NULL;
}
-bool CToxProto::InitToxCore(CToxThread *toxThread)
+void CToxProto::InitToxCore(Tox *tox)
{
debugLogA(__FUNCTION__": initializing tox core");
- if (toxThread == NULL)
- return false;
-
- tox_callback_friend_request(toxThread->Tox(), OnFriendRequest);
- tox_callback_friend_message(toxThread->Tox(), OnFriendMessage);
- tox_callback_friend_read_receipt(toxThread->Tox(), OnReadReceipt);
- tox_callback_friend_typing(toxThread->Tox(), OnTypingChanged);
+ tox_callback_friend_request(tox, OnFriendRequest);
+ tox_callback_friend_message(tox, OnFriendMessage);
+ tox_callback_friend_read_receipt(tox, OnReadReceipt);
+ tox_callback_friend_typing(tox, OnTypingChanged);
//
- tox_callback_friend_name(toxThread->Tox(), OnFriendNameChange);
- tox_callback_friend_status_message(toxThread->Tox(), OnStatusMessageChanged);
- tox_callback_friend_status(toxThread->Tox(), OnUserStatusChanged);
- tox_callback_friend_connection_status(toxThread->Tox(), OnConnectionStatusChanged);
+ tox_callback_friend_name(tox, OnFriendNameChange);
+ tox_callback_friend_status_message(tox, OnStatusMessageChanged);
+ tox_callback_friend_status(tox, OnUserStatusChanged);
+ tox_callback_friend_connection_status(tox, OnConnectionStatusChanged);
// transfers
- tox_callback_file_recv_control(toxThread->Tox(), OnFileRequest);
- tox_callback_file_recv(toxThread->Tox(), OnFriendFile);
- tox_callback_file_recv_chunk(toxThread->Tox(), OnDataReceiving);
- tox_callback_file_chunk_request(toxThread->Tox(), OnFileSendData);
+ tox_callback_file_recv_control(tox, OnFileRequest);
+ tox_callback_file_recv(tox, OnFriendFile);
+ tox_callback_file_recv_chunk(tox, OnDataReceiving);
+ tox_callback_file_chunk_request(tox, OnFileSendData);
// group chats
//tox_callback_group_invite(tox, OnGroupChatInvite, this);
// a/v
@@ -87,7 +84,7 @@ bool CToxProto::InitToxCore(CToxThread *toxThread) //}
uint8_t data[TOX_ADDRESS_SIZE];
- tox_self_get_address(toxThread->Tox(), data);
+ tox_self_get_address(tox, data);
ToxHexAddress address(data);
setString(TOX_SETTINGS_ID, address);
@@ -98,33 +95,22 @@ bool CToxProto::InitToxCore(CToxThread *toxThread) setWString("Nick", ptrW(Utf8DecodeW((char*)nick)));*/
ptrA nick(mir_utf8encodeW(ptrW(getWStringA("Nick"))));
- tox_self_set_name(toxThread->Tox(), (uint8_t*)(char*)nick, mir_strlen(nick), &error);
+ tox_self_set_name(tox, (uint8_t*)(char*)nick, mir_strlen(nick), &error);
if (error != TOX_ERR_SET_INFO_OK)
- {
debugLogA(__FUNCTION__": failed to set self name (%d)", error);
- return NULL;
- }
/*uint8_t statusMessage[TOX_MAX_STATUS_MESSAGE_LENGTH] = { 0 };
tox_self_get_status_message(toxThread->Tox(), statusMessage);
setWString("StatusMsg", ptrW(Utf8DecodeW((char*)statusMessage)));*/
ptrA statusMessage(mir_utf8encodeW(ptrW(getWStringA("StatusMsg"))));
- tox_self_set_status_message(toxThread->Tox(), (uint8_t*)(char*)statusMessage, mir_strlen(statusMessage), &error);
+ tox_self_set_status_message(tox, (uint8_t*)(char*)statusMessage, mir_strlen(statusMessage), &error);
if (error != TOX_ERR_SET_INFO_OK)
- {
debugLogA(__FUNCTION__": failed to set self status message (%d)", error);
- return NULL;
- }
-
- return true;
}
-void CToxProto::UninitToxCore(CToxThread *toxThread)
+void CToxProto::UninitToxCore(Tox *tox)
{
- if (toxThread == NULL)
- return;
-
- CancelAllTransfers(toxThread);
- SaveToxProfile(toxThread);
+ CancelAllTransfers(tox);
+ SaveToxProfile(tox);
}
\ No newline at end of file |