summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_account.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-09-29 17:47:24 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-09-29 17:47:24 +0000
commit6beb2d44b3ab2811417507be4c78c19626c9ee7e (patch)
tree0292dd1424658b2a34850dfaebafe2bdde36bfdc /protocols/Tox/src/tox_account.cpp
parent8f994ff592a5501018ba601d33d59a558a2d9840 (diff)
Tox:
- profile manager is now profile import - tox profile renaming without reloading of tox core - updated tox core git-svn-id: http://svn.miranda-ng.org/main/trunk@10632 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_account.cpp')
-rw-r--r--protocols/Tox/src/tox_account.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp
index 8921a5c437..5cd08f59b7 100644
--- a/protocols/Tox/src/tox_account.cpp
+++ b/protocols/Tox/src/tox_account.cpp
@@ -20,6 +20,21 @@ int CToxProto::OnAccountLoaded(WPARAM, LPARAM)
void CToxProto::InitToxCore()
{
+ std::tstring profilePath = GetToxProfilePath();
+ if (!IsFileExists(profilePath))
+ {
+ return;
+ }
+
+ hProfile = CreateFile(
+ profilePath.c_str(),
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ NULL,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL);
+
Tox_Options options = { 0 };
options.udp_disabled = getByte("DisableUDP", 0);
options.ipv6enabled = !getByte("DisableIPv6", 0);
@@ -59,7 +74,7 @@ void CToxProto::InitToxCore()
tox_callback_avatar_info(tox, OnGotFriendAvatarInfo, this);
tox_callback_avatar_data(tox, OnGotFriendAvatarData, this);
- LoadToxData();
+ LoadToxProfile();
int size = tox_get_self_name_size(tox);
std::vector<uint8_t> username(size);
@@ -81,8 +96,15 @@ void CToxProto::InitToxCore()
void CToxProto::UninitToxCore()
{
- SaveToxData();
+ std::tstring profilePath = GetToxProfilePath();
+ if (!IsFileExists(profilePath))
+ {
+ return;
+ }
+
+ SaveToxProfile();
tox_kill(tox);
+ CloseHandle(hProfile);
}
void CToxProto::DoBootstrap()