diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-09-12 19:17:35 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-09-12 19:17:35 +0000 |
commit | f4ddf8de528cb486816ed9a4e9e51b51a7b1b142 (patch) | |
tree | b617a29803b21e1912e92feb6cc0d2644c3d6da3 /protocols/Tox | |
parent | 124c695427c4999bd6a4ec97735b6fcac8975474 (diff) |
Tox: rename tox profile together with miranda account
git-svn-id: http://svn.miranda-ng.org/main/trunk@10440 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox')
-rw-r--r-- | protocols/Tox/src/tox_accounts.cpp | 34 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 1 |
3 files changed, 30 insertions, 9 deletions
diff --git a/protocols/Tox/src/tox_accounts.cpp b/protocols/Tox/src/tox_accounts.cpp index 147c328656..95b7284e93 100644 --- a/protocols/Tox/src/tox_accounts.cpp +++ b/protocols/Tox/src/tox_accounts.cpp @@ -27,16 +27,32 @@ int CToxProto::OnAccountListChanged(WPARAM wParam, LPARAM lParam) {
PROTOACCOUNT* account = (PROTOACCOUNT*)lParam;
- if (wParam == PRAC_ADDED && !strcmp(account->szModuleName, m_szModuleName))
+ if (!strcmp(account->szModuleName, m_szModuleName))
{
- UninitToxCore();
- DialogBoxParam(
- g_hInstance,
- MAKEINTRESOURCE(IDD_PROFILE_MANAGER),
- account->hwndAccMgrUI,
- CToxProto::ToxProfileManagerProc,
- (LPARAM)this);
- InitToxCore();
+ switch (wParam)
+ {
+ case PRAC_ADDED:
+ UninitToxCore();
+ DialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_PROFILE_MANAGER),
+ account->hwndAccMgrUI,
+ CToxProto::ToxProfileManagerProc,
+ (LPARAM)this);
+ InitToxCore();
+ break;
+
+ case PRAC_CHANGED:
+ UninitToxCore();
+ 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);
+ mir_free(accountName);
+ accountName = mir_tstrdup(m_tszUserName);
+ InitToxCore();
+ break;
+ }
}
return 0;
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 2461aa0518..d1e71ed376 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -3,6 +3,8 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) :
PROTO<CToxProto>(protoName, userName)
{
+ accountName = mir_tstrdup(userName);
+
InitToxCore();
CreateProtoService(PS_CREATEACCMGRUI, &CToxProto::OnAccountManagerInit);
@@ -42,6 +44,8 @@ PROTO<CToxProto>(protoName, userName) CToxProto::~CToxProto()
{
UninitToxCore();
+
+ mir_free(accountName);
}
DWORD_PTR __cdecl CToxProto::GetCaps(int type, MCONTACT hContact)
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 6c7b26ed34..e18c98f7b6 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -108,6 +108,7 @@ public: private:
Tox *tox;
mir_cs toxLock;
+ TCHAR *accountName;
HANDLE hNetlib, hPollingThread;
bool isTerminated, isConnected;
std::map<uint8_t, FileTransferParam*> transfers;
|