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/src | |
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/src')
-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 |
4 files changed, 49 insertions, 31 deletions
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);
|