From a8bb7b8d1f606b887c614d6200840fffb1bd48aa Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 18 Feb 2015 17:45:59 +0000 Subject: fixed label size in options profile import work only when protocol offline warning when importing in existing profile git-svn-id: http://svn.miranda-ng.org/main/trunk@12182 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/Tox_10.vcxproj | 8 ++--- protocols/Tox/Tox_12.vcxproj | 8 ++--- protocols/Tox/res/resource.rc | 14 ++++---- protocols/Tox/src/common.h | 1 + protocols/Tox/src/tox_network.cpp | 5 +++ protocols/Tox/src/tox_options.cpp | 73 ++++++++++++++++++++++----------------- protocols/Tox/src/tox_proto.h | 1 + 7 files changed, 64 insertions(+), 46 deletions(-) (limited to 'protocols') diff --git a/protocols/Tox/Tox_10.vcxproj b/protocols/Tox/Tox_10.vcxproj index 9712e4b8e0..84ae123b76 100644 --- a/protocols/Tox/Tox_10.vcxproj +++ b/protocols/Tox/Tox_10.vcxproj @@ -92,7 +92,7 @@ $(ProfileDir)..\..\bin10\lib $(IntDir)$(TargetName).lib false - ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) + Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) _DEBUG;%(PreprocessorDefinitions) @@ -120,7 +120,7 @@ true $(ProfileDir)..\..\bin10\lib $(IntDir)$(TargetName).lib - dnsapi.lib;comctl32.lib;%(AdditionalDependencies) + Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) false @@ -151,7 +151,7 @@ false $(ProfileDir)..\..\bin10\lib $(IntDir)$(TargetName).lib - dnsapi.lib;comctl32.lib;%(AdditionalDependencies) + Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) /PDBALTPATH:%_PDB% %(AdditionalOptions) @@ -180,7 +180,7 @@ true true false - dnsapi.lib;comctl32.lib;%(AdditionalDependencies) + Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) $(ProfileDir)..\..\bin10\lib $(IntDir)$(TargetName).lib /PDBALTPATH:%_PDB% %(AdditionalOptions) diff --git a/protocols/Tox/Tox_12.vcxproj b/protocols/Tox/Tox_12.vcxproj index 924717bba1..ac7a37cc8d 100644 --- a/protocols/Tox/Tox_12.vcxproj +++ b/protocols/Tox/Tox_12.vcxproj @@ -97,7 +97,7 @@ $(IntDir)$(TargetName).lib false false - ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) + Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) _DEBUG;%(PreprocessorDefinitions) @@ -125,7 +125,7 @@ true $(ProfileDir)..\..\bin12\lib $(IntDir)$(TargetName).lib - dnsapi.lib;comctl32.lib;%(AdditionalDependencies) + Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) false @@ -156,7 +156,7 @@ false $(ProfileDir)..\..\bin12\lib $(IntDir)$(TargetName).lib - dnsapi.lib;comctl32.lib;%(AdditionalDependencies) + Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) NDEBUG;%(PreprocessorDefinitions) @@ -184,7 +184,7 @@ true true false - dnsapi.lib;comctl32.lib;%(AdditionalDependencies) + Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies) $(ProfileDir)..\..\bin12\lib $(IntDir)$(TargetName).lib diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc index bcac80967a..4052639e78 100644 --- a/protocols/Tox/res/resource.rc +++ b/protocols/Tox/res/resource.rc @@ -93,7 +93,7 @@ BEGIN PUSHBUTTON "C",IDC_CLIPBOARD,170,7,16,13 LTEXT "Tox ID:",IDC_STATIC,12,9,54,8 EDITTEXT IDC_PASSWORD,66,38,120,12,ES_PASSWORD | ES_AUTOHSCROLL | NOT WS_VISIBLE - PUSHBUTTON "Import tox profile",IDC_IMPORT_PROFILE,66,72,100,14 + PUSHBUTTON "Import tox profile",IDC_IMPORT_PROFILE,66,72,100,14,WS_DISABLED LTEXT "Tox profile contains your ID and friend list.\r\nYou may import existing profile from other tox client.",IDC_STATIC,12,91,174,21 END @@ -106,18 +106,18 @@ BEGIN EDITTEXT IDC_NAME,81,33,219,12,ES_AUTOHSCROLL LTEXT "Tox ID:",IDC_STATIC,12,19,69,11 EDITTEXT IDC_TOXID,81,17,199,12,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Connection settings",IDC_STATIC,7,125,298,45 + GROUPBOX "Connection settings",IDC_STATIC,7,134,298,45 CONTROL "Disable UDP (force Tox to use TCP)",IDC_DISABLE_UDP, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,137,288,10 - CONTROL "Disable IPv6",IDC_DISABLE_IPV6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,152,288,10 - GROUPBOX "Tox",IDC_STATIC,7,7,298,116 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,146,288,10 + CONTROL "Disable IPv6",IDC_DISABLE_IPV6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,161,288,10 + GROUPBOX "Tox",IDC_STATIC,7,7,298,124 LTEXT "Default group:",IDC_STATIC,12,68,69,12 EDITTEXT IDC_GROUP,81,65,219,12,ES_AUTOHSCROLL PUSHBUTTON "C",IDC_CLIPBOARD,284,17,16,13 LTEXT "Password:",IDC_STATIC,12,51,69,8,NOT WS_VISIBLE EDITTEXT IDC_PASSWORD,81,49,219,12,ES_PASSWORD | ES_AUTOHSCROLL | NOT WS_VISIBLE - PUSHBUTTON "Import tox profile",IDC_IMPORT_PROFILE,81,83,100,14 - LTEXT "Tox profile contains your ID and friend list.\r\nYou may import existing profile from other tox client.",IDC_STATIC,81,100,219,21 + PUSHBUTTON "Import tox profile",IDC_IMPORT_PROFILE,81,83,100,14,WS_DISABLED + LTEXT "Tox profile contains your ID and friend list.\r\nYou may import existing profile from other tox client.",IDC_STATIC,81,100,219,27 END IDD_SEARCH DIALOGEX 0, 0, 109, 113 diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h index 81b1e1b717..4344557ffe 100644 --- a/protocols/Tox/src/common.h +++ b/protocols/Tox/src/common.h @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp index 19d90b719b..72f090fe76 100644 --- a/protocols/Tox/src/tox_network.cpp +++ b/protocols/Tox/src/tox_network.cpp @@ -5,6 +5,11 @@ bool CToxProto::IsOnline() return isConnected && m_iStatus > ID_STATUS_OFFLINE; } +bool CToxProto::IsOffline() +{ + return !isConnected && m_iStatus == ID_STATUS_OFFLINE; +} + void CToxProto::BootstrapDht() { debugLogA("CToxProto::BootstrapDht: bootstraping DHT"); diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index dec969d3b4..77a7e5e806 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -33,6 +33,8 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l CheckDlgButton(hwnd, IDC_DISABLE_UDP, proto->getBool("DisableUDP", 0)); CheckDlgButton(hwnd, IDC_DISABLE_IPV6, proto->getBool("DisableIPv6", 0)); + if (proto->IsOffline()) + EnableWindow(GetDlgItem(hwnd, IDC_IMPORT_PROFILE), TRUE); } return TRUE; @@ -88,41 +90,50 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l if (GetOpenFileName(&ofn)) { - std::tstring defaultProfilePath = GetToxProfilePath(proto->accountName); - if (profilePath && _tcslen(profilePath)) - { - if (_tcsicmp(profilePath, defaultProfilePath.c_str()) != 0) + if (proto->IsOffline()) { + std::tstring defaultProfilePath = GetToxProfilePath(proto->accountName); + if (PathFileExists(defaultProfilePath.c_str())) + if (MessageBox(hwnd, TranslateT("You have existing profile. Do you want remove it with all tox contacts and history and continue import?"), TranslateT("Tox profile import"), MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) == IDNO) + break; + else { + while (MCONTACT hContact = db_find_first(proto->m_szModuleName)) + CallService(MS_DB_CONTACT_DELETE, hContact, 0); + } + if (profilePath && _tcslen(profilePath)) { - CopyFile(profilePath, defaultProfilePath.c_str(), FALSE); + if (_tcsicmp(profilePath, defaultProfilePath.c_str()) != 0) + { + CopyFile(profilePath, defaultProfilePath.c_str(), FALSE); + } } - } - - if (proto->InitToxCore()) - { - TCHAR group[64]; - GetDlgItemText(hwnd, IDC_GROUP, group, SIZEOF(group)); - if (_tcslen(group) > 0) - { - proto->setTString(TOX_SETTINGS_GROUP, group); - Clist_CreateGroup(0, group); - } - else - { - proto->delSetting(TOX_SETTINGS_GROUP); - } - proto->LoadFriendList(NULL); - proto->UninitToxCore(); - - ptrT nick(proto->getTStringA("Nick")); - SetDlgItemText(hwnd, IDC_NAME, nick); - - ptrT pass(proto->getTStringA("Password")); - SetDlgItemText(hwnd, IDC_PASSWORD, pass); - ptrA address(proto->getStringA(TOX_SETTINGS_ID)); - if (address != NULL) + if (proto->InitToxCore()) { - SetDlgItemTextA(hwnd, IDC_TOXID, address); + TCHAR group[64]; + GetDlgItemText(hwnd, IDC_GROUP, group, SIZEOF(group)); + if (_tcslen(group) > 0) + { + proto->setTString(TOX_SETTINGS_GROUP, group); + Clist_CreateGroup(0, group); + } + else + { + proto->delSetting(TOX_SETTINGS_GROUP); + } + proto->LoadFriendList(NULL); + proto->UninitToxCore(); + + ptrT nick(proto->getTStringA("Nick")); + SetDlgItemText(hwnd, IDC_NAME, nick); + + ptrT pass(proto->getTStringA("Password")); + SetDlgItemText(hwnd, IDC_PASSWORD, pass); + + ptrA address(proto->getStringA(TOX_SETTINGS_ID)); + if (address != NULL) + { + SetDlgItemTextA(hwnd, IDC_TOXID, address); + } } } } diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index ecfcc94b50..f7844e1f61 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -88,6 +88,7 @@ private: // tox network bool IsOnline(); + bool IsOffline(); void BootstrapDht(); void TryConnect(); void CheckConnection(int &retriesCount); -- cgit v1.2.3