#include "stdafx.h" LIST CToxProto::Accounts(1, CToxProto::CompareAccounts); int CToxProto::CompareAccounts(const CToxProto *p1, const CToxProto *p2) { return mir_wstrcmp(p1->m_tszUserName, p2->m_tszUserName); } CToxProto* CToxProto::InitAccount(const char *protoName, const wchar_t *userName) { CToxProto *proto = new CToxProto(protoName, userName); Accounts.insert(proto); return proto; } int CToxProto::UninitAccount(CToxProto *proto) { Accounts.remove(proto); delete proto; return 0; } CToxProto* CToxProto::GetContactAccount(MCONTACT hContact) { for (auto &it : Accounts) if (mir_strcmpi(GetContactProto(hContact), it->m_szModuleName) == 0) return it; return nullptr; } int CToxProto::OnAccountLoaded(WPARAM, LPARAM) { Clist_GroupCreate(0, m_defaultGroup); HookProtoEvent(ME_OPT_INITIALISE, &CToxProto::OnOptionsInit); HookProtoEvent(ME_USERINFO_INITIALISE, &CToxProto::OnUserInfoInit); HookProtoEvent(ME_MSG_PRECREATEEVENT, &CToxProto::OnPreCreateMessage); InitCustomDbEvents(); return 0; } int CToxProto::OnAccountRenamed(WPARAM, LPARAM) { mir_cslock lock(m_profileLock); ptrW newPath(GetToxProfilePath()); wchar_t oldPath[MAX_PATH]; mir_snwprintf(oldPath, MAX_PATH, L"%s\\%s.tox", VARSW(L"%miranda_userdata%"), m_accountName); _wrename(oldPath, newPath); m_accountName = mir_wstrdup(m_tszUserName); return 0; } INT_PTR CToxProto::OnAccountManagerInit(WPARAM, LPARAM lParam) { return (INT_PTR)(CToxOptionsMain::CreateAccountManagerPage(this, (HWND)lParam))->GetHwnd(); }