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/src/tox_options.cpp | 73 ++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 31 deletions(-) (limited to 'protocols/Tox/src/tox_options.cpp') 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); + } } } } -- cgit v1.2.3