From ed9fa764b873d1ae27ab98249a5d3bb31c253bdb Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Mon, 7 Sep 2015 19:40:25 +0000 Subject: Tox: - change error message when tox core initialization is failed - trying to fix error with keepstatus reconnect git-svn-id: http://svn.miranda-ng.org/main/trunk@15297 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_core.cpp | 12 +++++++++++- protocols/Tox/src/tox_profile.cpp | 16 +++------------- protocols/Tox/src/tox_proto.cpp | 18 +++++++++++++----- protocols/Tox/src/tox_utils.cpp | 2 +- 4 files changed, 28 insertions(+), 20 deletions(-) (limited to 'protocols') diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index 242a2eafa9..c8d30cf2ce 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -31,7 +31,7 @@ bool CToxProto::InitToxCore() if (nlus.proxyType == PROXYTYPE_SOCKS4 || nlus.proxyType == PROXYTYPE_SOCKS5) { - debugLogA("CToxProto::InitToxCore: setting socks user proxy config"); + debugLogA(__FUNCTION__": setting socks user proxy config"); options->proxy_type = TOX_PROXY_TYPE_SOCKS5; mir_strcpy((char*)&options->proxy_host[0], nlus.szProxyServer); options->proxy_port = nlus.wProxyPort; @@ -41,6 +41,16 @@ bool CToxProto::InitToxCore() if (LoadToxProfile(options)) { + TOX_ERR_NEW initError; + tox = tox_new(options, &initError); + if (initError != TOX_ERR_NEW_OK) + { + debugLogA(__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(tox, OnFriendRequest, this); tox_callback_friend_message(tox, OnFriendMessage, this); tox_callback_friend_read_receipt(tox, OnReadReceipt, this); diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index 5980118043..d6fff1c75d 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -88,20 +88,10 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) options->savedata_data = data; options->savedata_length = size; options->savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE; + return true; } - - TOX_ERR_NEW initError; - tox = tox_new(options, &initError); - if (initError != TOX_ERR_NEW_OK) - { - debugLogA(__FUNCTION__": failed to load tox profile (%d)", initError); - ShowNotification(ToxErrorToString(initError), TranslateT("Unable to load Tox profile"), MB_ICONERROR); - mir_free(data); - return false; - } - mir_free(data); - debugLogA(__FUNCTION__": tox profile load successfully"); - return true; + + return false; } void CToxProto::SaveToxProfile() diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index b31d83f894..1718f9f0bc 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(protoName, userName), -tox(NULL), toxAv(NULL), password(NULL), -isTerminated(false), isConnected(false), -hPollingThread(NULL), hOutDevice(NULL) +CToxProto::CToxProto(const char* protoName, const TCHAR* userName) + : PROTO(protoName, userName), + tox(NULL), toxAv(NULL), password(NULL), + isTerminated(false), isConnected(false), + hPollingThread(NULL), hOutDevice(NULL) { InitNetlib(); @@ -174,6 +174,8 @@ int CToxProto::SetStatus(int iNewStatus) { // logout isTerminated = true; + WaitForSingleObject(hPollingThread, INFINITE); + hPollingThread = NULL; if (!Miranda_Terminated()) { @@ -192,6 +194,12 @@ int CToxProto::SetStatus(int iNewStatus) if (old_status == ID_STATUS_OFFLINE && !IsOnline()) { + if (hPollingThread != NULL) + { + m_iDesiredStatus = old_status; + return 0; + } + // login m_iStatus = ID_STATUS_CONNECTING; diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp index 223d3b1b70..e0a3e9f514 100644 --- a/protocols/Tox/src/tox_utils.cpp +++ b/protocols/Tox/src/tox_utils.cpp @@ -38,7 +38,7 @@ TCHAR* CToxProto::ToxErrorToString(TOX_ERR_NEW error) switch (error) { case TOX_ERR_NEW_NULL: - return TranslateT("One of the arguments is not valid or "); + return TranslateT("One of the arguments is missing"); case TOX_ERR_NEW_MALLOC: return TranslateT("Unable to allocate enough memory"); case TOX_ERR_NEW_PORT_ALLOC: -- cgit v1.2.3