diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2015-02-18 17:45:59 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2015-02-18 17:45:59 +0000 |
commit | a8bb7b8d1f606b887c614d6200840fffb1bd48aa (patch) | |
tree | 39edcab678f9da538f4516cf55275315c6c79b33 /protocols/Tox | |
parent | 64e4c45c42ce093c7e6e9a99a5a0938dc212aa59 (diff) |
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
Diffstat (limited to 'protocols/Tox')
-rw-r--r-- | protocols/Tox/Tox_10.vcxproj | 8 | ||||
-rw-r--r-- | protocols/Tox/Tox_12.vcxproj | 8 | ||||
-rw-r--r-- | protocols/Tox/res/resource.rc | 14 | ||||
-rw-r--r-- | protocols/Tox/src/common.h | 1 | ||||
-rw-r--r-- | protocols/Tox/src/tox_network.cpp | 5 | ||||
-rw-r--r-- | protocols/Tox/src/tox_options.cpp | 73 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 1 |
7 files changed, 64 insertions, 46 deletions
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 @@ <AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
- <AdditionalDependencies>ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -120,7 +120,7 @@ <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalDependencies>dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
</Link>
<ResourceCompile>
@@ -151,7 +151,7 @@ <RandomizedBaseAddress>false</RandomizedBaseAddress>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalDependencies>dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalOptions>/PDBALTPATH:%_PDB% %(AdditionalOptions)</AdditionalOptions>
</Link>
<ResourceCompile>
@@ -180,7 +180,7 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
- <AdditionalDependencies>dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin10\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
<AdditionalOptions>/PDBALTPATH:%_PDB% %(AdditionalOptions)</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 @@ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
- <AdditionalDependencies>ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -125,7 +125,7 @@ <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalDependencies>dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
</Link>
<ResourceCompile>
@@ -156,7 +156,7 @@ <RandomizedBaseAddress>false</RandomizedBaseAddress>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
- <AdditionalDependencies>dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@@ -184,7 +184,7 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
- <AdditionalDependencies>dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <AdditionalDependencies>Shlwapi.lib;ws2_32.lib;dnsapi.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(ProfileDir)..\..\bin12\lib</AdditionalLibraryDirectories>
<ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
</Link>
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 <windns.h>
#include <time.h>
#include <commctrl.h>
+#include <Shlwapi.h>
#include <string>
#include <sstream>
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);
|