summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_options.cpp
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2015-02-18 17:45:59 +0000
committerKirill Volinsky <mataes2007@gmail.com>2015-02-18 17:45:59 +0000
commita8bb7b8d1f606b887c614d6200840fffb1bd48aa (patch)
tree39edcab678f9da538f4516cf55275315c6c79b33 /protocols/Tox/src/tox_options.cpp
parent64e4c45c42ce093c7e6e9a99a5a0938dc212aa59 (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/src/tox_options.cpp')
-rw-r--r--protocols/Tox/src/tox_options.cpp73
1 files changed, 42 insertions, 31 deletions
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);
+ }
}
}
}