summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_account.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-10-04 02:12:42 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-10-04 02:12:42 +0000
commit6a3c12bfd2a1829ac537a3b615d42c1e956a0586 (patch)
tree79d2fa3338a7a8e2040481c0e11b82905efca2b5 /protocols/Tox/src/tox_account.cpp
parent928158d25b533037df6ba4a1b1daedeefb05bbbb (diff)
Tox:
- fixed network setting loading - code reordering git-svn-id: http://svn.miranda-ng.org/main/trunk@10680 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_account.cpp')
-rw-r--r--protocols/Tox/src/tox_account.cpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp
index a733d5f480..0262ba774e 100644
--- a/protocols/Tox/src/tox_account.cpp
+++ b/protocols/Tox/src/tox_account.cpp
@@ -10,11 +10,33 @@ int CToxProto::OnAccountLoaded(WPARAM, LPARAM)
{
HookProtoEvent(ME_OPT_INITIALISE, &CToxProto::OnOptionsInit);
HookProtoEvent(ME_USERINFO_INITIALISE, &CToxProto::OnUserInfoInit);
- HookProtoEvent(ME_PROTO_ACCLISTCHANGED, &CToxProto::OnAccountListChanged);
HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &CToxProto::OnSettingsChanged);
- HookProtoEvent(ME_MSG_PRECREATEEVENT, &CToxProto::OnPreCreateMessage);
+ HookProtoEvent(ME_MSG_PRECREATEEVENT, &CToxProto::OnPreCreateMessage);
InitNetlib();
+ InitToxCore();
+
+ return 0;
+}
+
+int CToxProto::OnAccountRenamed(WPARAM, LPARAM lParam)
+{
+ PROTOACCOUNT *account = (PROTOACCOUNT*)lParam;
+
+ std::tstring newPath = GetToxProfilePath();
+ TCHAR oldPath[MAX_PATH];
+ mir_sntprintf(oldPath, MAX_PATH, _T("%s\\%s.tox"), VARST(_T("%miranda_userdata%")), accountName);
+ MoveFileEx(oldPath, newPath.c_str(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_COPY_ALLOWED);
+ mir_free(accountName);
+ accountName = mir_tstrdup(m_tszUserName);
+
+ return 0;
+}
+
+int CToxProto::OnAccountUnloaded(WPARAM, LPARAM)
+{
+ UninitToxCore();
+ UninitNetlib();
return 0;
}
@@ -35,7 +57,7 @@ void CToxProto::InitToxCore()
options.udp_disabled = getByte("DisableUDP", 0);
options.ipv6enabled = !getByte("DisableIPv6", 0);
- if (hNetlib)
+ if (hNetlib != NULL)
{
NETLIBUSERSETTINGS nlus = { sizeof(NETLIBUSERSETTINGS) };
CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)hNetlib, (LPARAM)&nlus);