diff options
-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;
|