diff options
-rw-r--r-- | protocols/Tox/res/resource.rc | 13 | ||||
-rw-r--r-- | protocols/Tox/src/resource.h | 6 | ||||
-rw-r--r-- | protocols/Tox/src/stdafx.h | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_connection.cpp | 43 | ||||
-rw-r--r-- | protocols/Tox/src/tox_core.cpp | 5 | ||||
-rw-r--r-- | protocols/Tox/src/tox_options.cpp | 13 | ||||
-rw-r--r-- | protocols/Tox/src/tox_options.h | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 15 |
9 files changed, 24 insertions, 80 deletions
diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc index 2e49c71997..4674a8cb01 100644 --- a/protocols/Tox/res/resource.rc +++ b/protocols/Tox/res/resource.rc @@ -49,7 +49,7 @@ END /////////////////////////////////////////////////////////////////////////////
-// English resources
+// English (Neutral) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
@@ -68,6 +68,7 @@ IDI_ME ICON "me.ico" IDI_COPY ICON "copy.ico"
+
/////////////////////////////////////////////////////////////////////////////
//
// Dialog
@@ -108,16 +109,10 @@ BEGIN PUSHBUTTON "Import Tox profile",IDC_PROFILE_IMPORT,191,30,107,13
PUSHBUTTON "Copy Tox ID",IDC_CLIPBOARD,81,30,107,13,NOT WS_VISIBLE
PUSHBUTTON "Export Tox profile",IDC_PROFILE_EXPORT,191,30,107,13,NOT WS_VISIBLE
- GROUPBOX "Connection settings",IDC_STATIC,7,99,296,106
+ GROUPBOX "Connection settings",IDC_STATIC,7,99,296,68
CONTROL "Enable UDP (otherwise force Tox to use TCP)",IDC_ENABLE_UDP,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,111,286,10
CONTROL "Enable IPv6",IDC_ENABLE_IPV6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,139,286,10
- LTEXT "Max connect retries:",IDC_STATIC,12,171,121,8
- EDITTEXT IDC_MAXCONNECTRETRIES,133,168,43,14,ES_NUMBER
- CONTROL "",IDC_MAXCONNECTRETRIESSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,166,168,10,14
- EDITTEXT IDC_MAXRECONNECTRETRIES,133,184,43,14,ES_NUMBER
- CONTROL "",IDC_MAXRECONNECTRETRIESSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,166,184,10,14
- LTEXT "Max reconnect retries:",IDC_STATIC,12,186,121,8
CONTROL "Enable UDP hole-punching",IDC_ENABLE_HOLEPUNCHING,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,125,274,10
CONTROL "Enable local network peer discovery",IDC_ENABLE_LOCALDISCOVERY,
@@ -333,7 +328,7 @@ BEGIN 0
END
-#endif // English resources
+#endif // English (Neutral) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h index db0cf0fc55..7202ebe883 100644 --- a/protocols/Tox/src/resource.h +++ b/protocols/Tox/src/resource.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by D:\Projects\c++\miranda-ng\protocols\Tox\res\resource.rc
+// Used by W:\miranda-ng\protocols\Tox\res\resource.rc
//
#define IDI_TOX 100
#define IDI_ME 101
@@ -44,10 +44,6 @@ #define IDC_PASSWORD_CHANGE2 1020
#define IDC_PASSWORD_CREATE 1020
#define IDC_UPDATENODES 1021
-#define IDC_MAXCONNECTRETRIES 1025
-#define IDC_MAXRECONNECTRETRIES 1026
-#define IDC_MAXCONNECTRETRIESSPIN 1027
-#define IDC_MAXRECONNECTRETRIESSPIN 1028
#define IDC_PASSWORD_NEW 1029
#define IDC_PASSWORD_CONFIRM 1030
#define IDC_PASSWORD_VALIDATION 1031
diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h index a30c3155ee..865d98c2db 100644 --- a/protocols/Tox/src/stdafx.h +++ b/protocols/Tox/src/stdafx.h @@ -53,9 +53,6 @@ class CToxProto; #define TOX_DEFAULT_INTERVAL 50
#define TOX_CHECKING_INTERVAL 1000
-#define TOX_MAX_CONNECT_RETRIES 10
-#define TOX_MAX_RECONNECT_RETRIES 10
-
#define TOX_INI_PATH "%miranda_path%\\Plugins\\tox.ini"
#define TOX_JSON_PATH L"%miranda_userdata%\\tox.json"
diff --git a/protocols/Tox/src/tox_connection.cpp b/protocols/Tox/src/tox_connection.cpp index 6a3d9309df..56c1d7a901 100644 --- a/protocols/Tox/src/tox_connection.cpp +++ b/protocols/Tox/src/tox_connection.cpp @@ -19,49 +19,26 @@ void CToxProto::OnLoggedIn() UpdateStatusMenu(NULL, NULL); - m_impl.timerPoll.Start(TOX_DEFAULT_INTERVAL); - LoadFriendList(m_tox); } void CToxProto::OnLoggedFail() { - int maxConnectRetries = getByte("MaxConnectRetries", TOX_MAX_CONNECT_RETRIES); - - if (m_iStatus > ID_STATUS_OFFLINE) { - if (m_retriesCount == maxConnectRetries) { - m_retriesCount--; - debugLogA(__FUNCTION__": lost connection with DHT"); - return; - } - - if (!(--m_retriesCount)) { - debugLogA(__FUNCTION__": disconnected from DHT"); - SetStatus(ID_STATUS_OFFLINE); - return; - } - } - else { - if (m_iStatus++ > maxConnectRetries) { - SetStatus(ID_STATUS_OFFLINE); - ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_NONETWORK); - debugLogA(__FUNCTION__": failed to connect to DHT"); - } - } + SetStatus(ID_STATUS_OFFLINE); + ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, nullptr, LOGINERR_NONETWORK); + debugLogA(__FUNCTION__": failed to connect to DHT"); } -void CToxProto::OnToxCheck() +void CToxProto::OnConnectionStatus(Tox*, Tox_Connection iNewStatus, void *pUserData) { - if (m_tox == nullptr) + auto *ppro = (CToxProto *)pUserData; + if (ppro->m_tox == nullptr) return; - int iStatus = tox_self_get_connection_status(m_tox); - if (iStatus == TOX_CONNECTION_NONE) - OnLoggedFail(); - else if (iStatus != m_prevToxStatus) - OnLoggedIn(); - - m_prevToxStatus = iStatus; + if (iNewStatus == TOX_CONNECTION_NONE) + ppro->OnLoggedFail(); + else + ppro->OnLoggedIn(); } void CToxProto::OnToxPoll() diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index c9888f34cf..2344a69f83 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -66,8 +66,7 @@ void CToxProto::InitThread(void *) InitToxCore(m_tox);
BootstrapNodes(m_tox);
- m_prevToxStatus = TOX_CONNECTION_NONE;
- m_impl.timerCheck.StartSafe(TOX_CHECKING_INTERVAL);
+ m_impl.timerPoll.StartSafe(TOX_DEFAULT_INTERVAL);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -79,6 +78,8 @@ void CToxProto::InitToxCore(Tox *tox) if (tox == nullptr)
return;
+ tox_callback_self_connection_status(tox, OnConnectionStatus);
+
tox_callback_friend_request(tox, OnFriendRequest);
tox_callback_friend_message(tox, OnFriendMessage);
tox_callback_friend_read_receipt(tox, OnReadReceipt);
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index befeb245eb..330872e6f2 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -1,7 +1,7 @@ #include "stdafx.h"
-CToxOptionsMain::CToxOptionsMain(CToxProto *proto, int idDialog)
- : CToxDlgBase(proto, idDialog),
+CToxOptionsMain::CToxOptionsMain(CToxProto *proto, int idDialog) :
+ CToxDlgBase(proto, idDialog),
m_toxAddress(this, IDC_TOXID),
m_toxAddressCopy(this, IDC_CLIPBOARD),
m_profileCreate(this, IDC_PROFILE_NEW),
@@ -14,9 +14,7 @@ CToxOptionsMain::CToxOptionsMain(CToxProto *proto, int idDialog) m_group(this, IDC_GROUP),
m_enableUdp(this, IDC_ENABLE_UDP), m_enableUdpHolePunching(this, IDC_ENABLE_HOLEPUNCHING),
m_enableIPv6(this, IDC_ENABLE_IPV6),
- m_enableLocalDiscovery(this, IDC_ENABLE_LOCALDISCOVERY),
- m_maxConnectRetries(this, IDC_MAXCONNECTRETRIESSPIN, 255, 1),
- m_maxReconnectRetries(this, IDC_MAXRECONNECTRETRIESSPIN, 255, 1)
+ m_enableLocalDiscovery(this, IDC_ENABLE_LOCALDISCOVERY)
{
CreateLink(m_toxAddress, TOX_SETTINGS_ID, L"");
CreateLink(m_nickname, "Nick", L"");
@@ -26,11 +24,6 @@ CToxOptionsMain::CToxOptionsMain(CToxProto *proto, int idDialog) CreateLink(m_enableIPv6, "EnableIPv6", DBVT_BYTE, FALSE);
CreateLink(m_enableLocalDiscovery, "EnableLocalDiscovery", DBVT_BYTE, FALSE);
- if (idDialog == IDD_OPTIONS_MAIN) {
- CreateLink(m_maxConnectRetries, "MaxConnectRetries", DBVT_BYTE, TOX_MAX_CONNECT_RETRIES);
- CreateLink(m_maxReconnectRetries, "MaxReconnectRetries", DBVT_BYTE, TOX_MAX_RECONNECT_RETRIES);
- }
-
m_passwordCreate.OnClick = Callback(this, &CToxOptionsMain::PasswordCreate_OnClick);
m_passwordChange.OnClick = Callback(this, &CToxOptionsMain::PasswordChange_OnClick);
m_passwordRemove.OnClick = Callback(this, &CToxOptionsMain::PasswordRemove_OnClick);
diff --git a/protocols/Tox/src/tox_options.h b/protocols/Tox/src/tox_options.h index fdc8ea7402..bbe922e92c 100644 --- a/protocols/Tox/src/tox_options.h +++ b/protocols/Tox/src/tox_options.h @@ -24,9 +24,6 @@ private: CCtrlCheck m_enableIPv6;
CCtrlCheck m_enableLocalDiscovery;
- CCtrlSpin m_maxConnectRetries;
- CCtrlSpin m_maxReconnectRetries;
-
protected:
bool OnInitDialog() override;
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index f8f9ec4001..07a6d20cd1 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -164,7 +164,6 @@ int CToxProto::SetStatus(int iNewStatus) // logout
if (iNewStatus == ID_STATUS_OFFLINE) {
m_impl.timerPoll.Stop();
- m_impl.timerCheck.Stop();
if (m_tox) {
UninitToxCore(m_tox);
@@ -192,8 +191,6 @@ int CToxProto::SetStatus(int iNewStatus) m_iStatus = ID_STATUS_CONNECTING;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
- m_retriesCount = getByte("MaxConnectRetries", TOX_MAX_CONNECT_RETRIES);
-
ForkThread(&CToxProto::InitThread);
return 0;
}
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 362f8980df..be9746c463 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -14,11 +14,7 @@ class CToxProto : public PROTO<CToxProto> friend class CToxProto;
CToxProto &m_proto;
- CTimer timerCheck, timerPoll;
-
- void OnCheck(CTimer *) {
- m_proto.OnToxCheck();
- }
+ CTimer timerPoll;
void OnPoll(CTimer *) {
m_proto.OnToxPoll();
@@ -26,11 +22,9 @@ class CToxProto : public PROTO<CToxProto> Impl(CToxProto &ppro) :
m_proto(ppro),
- timerPoll(Miranda_GetSystemWindow(), UINT_PTR(this)),
- timerCheck(Miranda_GetSystemWindow(), UINT_PTR(this) + 1)
+ timerPoll(Miranda_GetSystemWindow(), UINT_PTR(this))
{
timerPoll.OnEvent = Callback(this, &Impl::OnPoll);
- timerCheck.OnEvent = Callback(this, &Impl::OnCheck);
}
}
m_impl;
@@ -95,9 +89,6 @@ private: CTransferList transfers;
ULONG hMessageProcess;
- int m_retriesCount;
- int m_prevToxStatus = TOX_CONNECTION_NONE;
-
static HANDLE hProfileFolderPath;
// tox profile
@@ -137,8 +128,8 @@ private: void OnLoggedIn();
void OnLoggedFail();
- void OnToxCheck();
void OnToxPoll();
+ static void OnConnectionStatus(Tox *, Tox_Connection iNewStatus, void *pUserData);
// accounts
int __cdecl OnAccountRenamed(WPARAM, LPARAM);
|