From d73ec8491056f109d8470b973e9f514a26644010 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 17 Aug 2014 08:49:56 +0000 Subject: Tox: - updated tox lib - ability to disable udp - ability to disable ipv6 - socks proxy support git-svn-id: http://svn.miranda-ng.org/main/trunk@10212 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_proto.cpp | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) (limited to 'protocols/Tox/src/tox_proto.cpp') diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index d63ea49b7a..5da018a496 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -3,23 +3,8 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) : PROTO(protoName, userName) { - tox = tox_new(TOX_ENABLE_IPV6_DEFAULT); - - LoadToxData(); - - std::vector username(TOX_MAX_NAME_LENGTH); - tox_get_self_name(tox, &username[0]); - std::string nick(username.begin(), username.end()); - setString("Nick", nick.c_str()); - - tox_callback_friend_request(tox, OnFriendRequest, this); - tox_callback_friend_message(tox, OnFriendMessage, this); - tox_callback_friend_action(tox, OnAction, this); - tox_callback_name_change(tox, OnFriendNameChange, this); - tox_callback_status_message(tox, OnStatusMessageChanged, this); - tox_callback_user_status(tox, OnUserStatusChanged, this); - tox_callback_read_receipt(tox, OnReadReceipt, this); - tox_callback_connection_status(tox, OnConnectionStatusChanged, this); + InitNetlib(); + InitToxCore(); CreateProtoService(PS_CREATEACCMGRUI, &CToxProto::OnAccountManagerInit); @@ -50,9 +35,8 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) : CToxProto::~CToxProto() { - SaveToxData(); - - tox_kill(tox); + UninitToxCore(); + UninitNetlib(); } DWORD_PTR __cdecl CToxProto::GetCaps(int type, MCONTACT hContact) @@ -181,16 +165,11 @@ HANDLE __cdecl CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescrip int __cdecl CToxProto::SendMsg(MCONTACT hContact, int flags, const char* msg) { - if (!IsOnline() || !hContact || !IsContactOnline(hContact)) - { - return 0; - } - std::string toxId(getStringA(hContact, TOX_SETTINGS_ID)); std::vector clientId = HexStringToData(toxId); uint32_t number = tox_get_friend_number(tox, clientId.data()); - + ULONG messageId = InterlockedIncrement(&hMessageProcess); int result = tox_send_message_withid(tox, number, messageId, (uint8_t*)msg, strlen(msg)); @@ -199,7 +178,7 @@ int __cdecl CToxProto::SendMsg(MCONTACT hContact, int flags, const char* msg) debugLogA("CToxProto::SendMsg: error sending message %i", result); return 0; } - + return messageId; } -- cgit v1.2.3