diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-08-18 20:17:45 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-08-18 20:17:45 +0000 |
commit | 87204c540590feeba783f40319d4a503b9f325f5 (patch) | |
tree | 60f3cee948264d9edd06958a15bb2e0b333deda1 /protocols | |
parent | 108d975c5775d83357c735541ee5e711c27f092a (diff) |
Tox:
- added profile manager on first run
- reworked options
git-svn-id: http://svn.miranda-ng.org/main/trunk@10231 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Tox/res/resource.rc | bin | 4280 -> 10788 bytes | |||
-rw-r--r-- | protocols/Tox/src/resource.h | bin | 1644 -> 2006 bytes | |||
-rw-r--r-- | protocols/Tox/src/tox_account.cpp | 15 | ||||
-rw-r--r-- | protocols/Tox/src/tox_events.cpp | 54 | ||||
-rw-r--r-- | protocols/Tox/src/tox_options.cpp | 159 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 30 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 12 | ||||
-rw-r--r-- | protocols/Tox/src/tox_utils.cpp | 44 |
8 files changed, 196 insertions, 118 deletions
diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc Binary files differindex dc60b0fb0a..a44995a8bf 100644 --- a/protocols/Tox/res/resource.rc +++ b/protocols/Tox/res/resource.rc diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h Binary files differindex 2c58072de5..eceb7f7415 100644 --- a/protocols/Tox/src/resource.h +++ b/protocols/Tox/src/resource.h diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp index f78f8b24a2..6ca734d0e4 100644 --- a/protocols/Tox/src/tox_account.cpp +++ b/protocols/Tox/src/tox_account.cpp @@ -1,11 +1,6 @@ #include "common.h"
#include "tox_bootstrap.h"
-bool CToxProto::IsOnline()
-{
- return isConnected && m_iStatus > ID_STATUS_OFFLINE;
-}
-
void CToxProto::InitToxCore()
{
Tox_Options options = { 0 };
@@ -21,7 +16,7 @@ void CToxProto::InitToxCore() {
if (nlus.proxyType == PROXYTYPE_SOCKS4 || nlus.proxyType == PROXYTYPE_SOCKS5)
{
- debugLogA("Setting socks user proxy config");
+ debugLogA("CToxProto::InitToxCore: Setting socks user proxy config");
options.proxy_enabled = 1;
strcpy(&options.proxy_address[0], nlus.szProxyServer);
options.proxy_port = nlus.wProxyPort;
@@ -50,13 +45,15 @@ void CToxProto::InitToxCore() void CToxProto::UninitToxCore()
{
- isTerminated = isConnected = false;
-
SaveToxData();
-
tox_kill(tox);
}
+bool CToxProto::IsOnline()
+{
+ return isConnected && m_iStatus > ID_STATUS_OFFLINE;
+}
+
void CToxProto::DoBootstrap()
{
static int j = 0;
diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp index 10f3c29701..38f6d1d493 100644 --- a/protocols/Tox/src/tox_events.cpp +++ b/protocols/Tox/src/tox_events.cpp @@ -1,14 +1,19 @@ #include "common.h"
-int CToxProto::OnModulesLoaded(WPARAM, LPARAM)
+int CToxProto::OnAccountLoaded(WPARAM, LPARAM)
{
HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, this);
+ HookEventObj(ME_PROTO_ACCLISTCHANGED, OnAccountListChanged, this);
+
+ InitNetlib();
return 0;
}
int CToxProto::OnPreShutdown(WPARAM, LPARAM)
{
+ UninitNetlib();
+
return 0;
}
@@ -16,13 +21,33 @@ INT_PTR CToxProto::OnAccountManagerInit(WPARAM, LPARAM lParam) {
return (INT_PTR)CreateDialogParam(
g_hInstance,
- MAKEINTRESOURCE(IDD_ACCMGR),
+ MAKEINTRESOURCE(IDD_ACCOUNT_MANAGER),
(HWND)lParam,
- &CToxProto::MainOptionsProc,
+ CToxProto::MainOptionsProc,
(LPARAM)this);
}
-int CToxProto::OnOptionsInit(void *obj, WPARAM wParam, LPARAM lParam)
+int CToxProto::OnAccountListChanged(void *obj, WPARAM wParam, LPARAM lParam)
+{
+ CToxProto *proto = (CToxProto*)obj;
+ PROTOACCOUNT* account = (PROTOACCOUNT*)lParam;
+
+ if (wParam == PRAC_ADDED && !strcmp(account->szModuleName, proto->m_szModuleName))
+ {
+ proto->UninitToxCore();
+ DialogBoxParam(
+ g_hInstance,
+ MAKEINTRESOURCE(IDD_PROFILE_MANAGER),
+ account->hwndAccMgrUI,
+ CToxProto::ToxProfileManagerProc,
+ (LPARAM)proto);
+ proto->InitToxCore();
+ }
+
+ return 0;
+}
+
+int CToxProto::OnOptionsInit(void *obj, WPARAM wParam, LPARAM)
{
CToxProto *proto = (CToxProto*)obj;
@@ -36,7 +61,7 @@ int CToxProto::OnOptionsInit(void *obj, WPARAM wParam, LPARAM lParam) odp.pszGroup = LPGEN("Network");
odp.pszTab = LPGEN("Account");
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_MAIN);
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_MAIN);
odp.pfnDlgProc = MainOptionsProc;
Options_AddPage(wParam, &odp);
@@ -45,9 +70,8 @@ int CToxProto::OnOptionsInit(void *obj, WPARAM wParam, LPARAM lParam) return 0;
}
-INT_PTR CToxProto::OnContactDeleted(WPARAM wParam, LPARAM)
+int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM lParam)
{
- MCONTACT hContact = (MCONTACT)wParam;
if (hContact)
{
std::string toxId(getStringA(hContact, TOX_SETTINGS_ID));
@@ -65,6 +89,20 @@ INT_PTR CToxProto::OnContactDeleted(WPARAM wParam, LPARAM) return 1;
}
+int CToxProto::OnSettingsChanged(MCONTACT hContact, LPARAM lParam)
+{
+ DBCONTACTWRITESETTING* dbcws = (DBCONTACTWRITESETTING*)lParam;
+ if (hContact == NULL && !strcmp(dbcws->szModule, m_szModuleName) && !strcmp(dbcws->szSetting, "Nick"))
+ {
+ if (tox_set_name(tox, (uint8_t*)(char*)ptrA(mir_utf8encodeW(dbcws->value.ptszVal)), _tcslen(dbcws->value.ptszVal)))
+ {
+ SaveToxData();
+ }
+ }
+
+ return 0;
+}
+
void CToxProto::OnFriendRequest(Tox *tox, const uint8_t *userId, const uint8_t *message, const uint16_t messageSize, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
@@ -91,7 +129,7 @@ void CToxProto::OnFriendMessage(Tox *tox, const int friendnumber, const uint8_t PROTORECVEVENT recv = { 0 };
recv.flags = PREF_UTF;
recv.timestamp = time(NULL);
- recv.szMessage = mir_strdup((char*)message);
+ recv.szMessage = (char*)message;
ProtoChainRecvMsg(hContact, &recv);
}
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index ccf6ae571e..61df8854e9 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -12,18 +12,15 @@ INT_PTR CALLBACK CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, proto = (CToxProto*)lParam;
SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
- ptrA username(proto->getStringA("Username"));
- SetDlgItemTextA(hwnd, IDC_USERNAME, username);
+ ptrW nick(proto->getTStringA("Nick"));
+ SetDlgItemText(hwnd, IDC_NAME, nick);
- std::string toxProfilePath = proto->GetToxProfilePath();
- SetDlgItemTextA(hwnd, IDC_DATAPATH, toxProfilePath.c_str());
-
- ptrW groupName(proto->getTStringA(TOX_SETTINGS_GROUP));
- SetDlgItemText(hwnd, IDC_GROUP, groupName);
+ ptrW group(proto->getTStringA(TOX_SETTINGS_GROUP));
+ SetDlgItemText(hwnd, IDC_GROUP, group);
SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, 64, 0);
CheckDlgButton(hwnd, IDC_DISABLE_UDP, proto->getByte("DisableUDP", 0));
- CheckDlgButton(hwnd, IDC_DISABLE_IPV6, proto->getByte("DisableIPv6", 0));
+ CheckDlgButton(hwnd, IDC_DISABLE_IPV6, proto->getByte("DisableIPv6", 1));
}
return TRUE;
@@ -31,57 +28,18 @@ INT_PTR CALLBACK CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, {
switch (LOWORD(wParam))
{
- case IDC_USERNAME:
- if ((HWND)lParam == GetFocus())
- {
- if (HIWORD(wParam) != EN_CHANGE) return 0;
- char username[128];
- GetDlgItemTextA(hwnd, IDC_USERNAME, username, SIZEOF(username));
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- break;
-
- case IDC_DATAPATH:
+ case IDC_NAME:
if ((HWND)lParam == GetFocus())
{
if (HIWORD(wParam) != EN_CHANGE) return 0;
- char dataPath[128];
- GetDlgItemTextA(hwnd, IDC_DATAPATH, dataPath, SIZEOF(dataPath));
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
break;
- case IDC_BROWSE:
- {
- char dataPath[MAX_PATH];
- GetDlgItemTextA(hwnd, IDC_DATAPATH, dataPath, SIZEOF(dataPath));
-
- char filter[MAX_PATH] = "";
- mir_snprintf(filter, MAX_PATH, "%s\0*.*\0", Translate("All files (*.*)"));
-
- OPENFILENAMEA ofn = { 0 };
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = 0;
- ofn.lpstrFilter = filter;
- ofn.nFilterIndex = 1;
- ofn.lpstrFile = dataPath;
- ofn.lpstrTitle = Translate("Select data file");
- ofn.nMaxFile = SIZEOF(dataPath);
- ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_NOCHANGEDIR;
- if (GetOpenFileNameA(&ofn) && dataPath[0])
- {
- SetDlgItemTextA(hwnd, IDC_DATAPATH, dataPath);
- SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
- }
- break;
-
case IDC_GROUP:
- {
if ((HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
return 0;
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
- }
break;
case IDC_DISABLE_UDP:
@@ -98,34 +56,107 @@ INT_PTR CALLBACK CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, case WM_NOTIFY:
if (reinterpret_cast<NMHDR*>(lParam)->code == PSN_APPLY)
{
- char username[128];
- GetDlgItemTextA(hwnd, IDC_USERNAME, username, SIZEOF(username));
- proto->setString("Username", username);
- tox_set_name(proto->tox, (uint8_t*)&username[0], strlen(username));
+ TCHAR nick[TOX_MAX_NAME_LENGTH];
+ GetDlgItemText(hwnd, IDC_NAME, nick, TOX_MAX_NAME_LENGTH);
+ proto->setTString("Nick", nick);
proto->setByte("DisableUDP", (BYTE)IsDlgButtonChecked(hwnd, IDC_DISABLE_UDP));
proto->setByte("DisableIPv6", (BYTE)IsDlgButtonChecked(hwnd, IDC_DISABLE_IPV6));
- wchar_t groupName[128];
- GetDlgItemText(hwnd, IDC_GROUP, groupName, SIZEOF(groupName));
- if (lstrlen(groupName) > 0)
+ TCHAR group[64];
+ GetDlgItemText(hwnd, IDC_GROUP, group, SIZEOF(group));
+ if (_tcslen(group) > 0)
{
- proto->setWString(NULL, TOX_SETTINGS_GROUP, groupName);
- Clist_CreateGroup(0, groupName);
+ proto->setTString(NULL, TOX_SETTINGS_GROUP, group);
+ Clist_CreateGroup(0, group);
}
else
+ {
proto->delSetting(NULL, TOX_SETTINGS_GROUP);
+ }
+
+ return TRUE;
+ }
+ break;
+ }
+
+ return FALSE;
+}
+
+INT_PTR CALLBACK CToxProto::ToxProfileManagerProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ CToxProto *proto = (CToxProto*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ TCHAR *profilePath = (TCHAR*)GetWindowLongPtr(hwnd, DWL_USER);
- char dataPath[128];
- GetDlgItemTextA(hwnd, IDC_DATAPATH, dataPath, SIZEOF(dataPath));
- if (proto->GetToxProfilePath().compare(dataPath) != 0)
+ switch (uMsg)
+ {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwnd);
+ {
+ proto = (CToxProto*)lParam;
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
+
+ profilePath = (TCHAR*)mir_calloc(sizeof(TCHAR) * MAX_PATH);
+ SetWindowLongPtr(hwnd, DWL_USER, (LONG_PTR)profilePath);
+
+ CheckDlgButton(hwnd, IDC_CREATE_NEW, TRUE);
+ }
+ return TRUE;
+
+ case WM_CLOSE:
+ EndDialog(hwnd, 0);
+ break;
+
+ case WM_DESTROY:
+ mir_free(profilePath);
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam))
+ {
+ case IDC_USE_EXISTING:
+ EnableWindow(GetDlgItem(hwnd, IDC_PROFILE_PATH), IsDlgButtonChecked(hwnd, IDC_USE_EXISTING));
+ EnableWindow(GetDlgItem(hwnd, IDC_BROWSE_PROFILE), IsDlgButtonChecked(hwnd, IDC_USE_EXISTING));
+ break;
+
+ case IDC_BROWSE_PROFILE:
{
- proto->UninitToxCore();
- proto->setString("DataPath", dataPath);
- proto->InitToxCore();
+ TCHAR filter[MAX_PATH] = { 0 };
+ mir_sntprintf(filter, MAX_PATH, _T("%s\0*.*"), TranslateT("All files (*.*)"));
+
+ OPENFILENAME ofn = { sizeof(ofn) };
+ ofn.hwndOwner = hwnd;
+ ofn.lpstrFilter = filter;
+ ofn.nFilterIndex = 1;
+ ofn.lpstrFile = profilePath;
+ ofn.lpstrTitle = TranslateT("Select tox profile");
+ ofn.nMaxFile = MAX_PATH;
+ ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_EXPLORER;
+
+ if (GetOpenFileName(&ofn) && profilePath)
+ {
+ SetDlgItemText(hwnd, IDC_PROFILE_PATH, profilePath);
+ }
}
+ break;
- return TRUE;
+ case IDOK:
+ {
+ if (IsDlgButtonChecked(hwnd, IDC_USE_EXISTING))
+ {
+ if (profilePath != NULL)
+ {
+ std::tstring toxProfilePath = proto->GetToxProfilePath();
+ CopyFile(profilePath, toxProfilePath.c_str(), FALSE);
+ }
+ }
+ EndDialog(hwnd, 1);
+ }
+ break;
+
+ case IDCANCEL:
+ EndDialog(hwnd, 0);
+ break;
}
break;
}
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 91f6eca7cc..eedddf74fc 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -3,7 +3,6 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) :
PROTO<CToxProto>(protoName, userName)
{
- InitNetlib();
InitToxCore();
CreateProtoService(PS_CREATEACCMGRUI, &CToxProto::OnAccountManagerInit);
@@ -34,7 +33,6 @@ CToxProto::CToxProto(const char* protoName, const TCHAR* userName) : CToxProto::~CToxProto()
{
UninitToxCore();
- UninitNetlib();
}
DWORD_PTR __cdecl CToxProto::GetCaps(int type, MCONTACT hContact)
@@ -153,7 +151,13 @@ int __cdecl CToxProto::RecvFile(MCONTACT hContact, PROTOFILEEVENT*) { return 0; int __cdecl CToxProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
{
- return (INT_PTR)AddDbEvent(hContact, EVENTTYPE_MESSAGE, pre->timestamp, DBEF_UTF, lstrlenA(pre->szMessage), (BYTE*)pre->szMessage);
+ return (INT_PTR)AddDbEvent(
+ hContact,
+ EVENTTYPE_MESSAGE,
+ pre->timestamp,
+ DBEF_UTF,
+ lstrlenA(pre->szMessage),
+ (BYTE*)pre->szMessage);
}
int __cdecl CToxProto::RecvUrl(MCONTACT hContact, PROTORECVEVENT*) { return 0; }
@@ -192,17 +196,16 @@ int __cdecl CToxProto::SetStatus(int iNewStatus) if (iNewStatus == ID_STATUS_OFFLINE)
{
// logout
- isTerminated = isConnected = false;
- m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
-
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
+ isTerminated = true;
+ isConnected = false;
if (!Miranda_Terminated())
{
SetAllContactsStatus(ID_STATUS_OFFLINE);
}
- return 0;
+ m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
}
else
{
@@ -210,7 +213,7 @@ int __cdecl CToxProto::SetStatus(int iNewStatus) {
m_iStatus = ID_STATUS_CONNECTING;
- DoBootstrap();
+ isTerminated = isConnected = false;
hPollingThread = ForkThreadEx(&CToxProto::PollingThread, 0, NULL);
}
else
@@ -220,10 +223,6 @@ int __cdecl CToxProto::SetStatus(int iNewStatus) {
SaveToxData();
}
-
- ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
-
- return 0;
}
}
@@ -243,11 +242,14 @@ int __cdecl CToxProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM switch (iEventType)
{
case EV_PROTO_ONLOAD:
- return OnModulesLoaded(wParam, lParam);
+ return OnAccountLoaded(wParam, lParam);
case EV_PROTO_ONCONTACTDELETED:
return OnContactDeleted(wParam, lParam);
+ case EV_PROTO_DBSETTINGSCHANGED:
+ return OnSettingsChanged(wParam, lParam);
+
case EV_PROTO_ONEXIT:
return OnPreShutdown(wParam, lParam);
}
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 537e001cdb..af596b689c 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -97,14 +97,15 @@ private: void __cdecl PollingThread(void*);
//events
- int __cdecl OnModulesLoaded(WPARAM, LPARAM);
+ int __cdecl OnAccountLoaded(WPARAM, LPARAM);
+ int __cdecl OnContactDeleted(WPARAM, LPARAM);
+ int __cdecl OnSettingsChanged(WPARAM, LPARAM);
int __cdecl OnPreShutdown(WPARAM, LPARAM);
INT_PTR __cdecl OnAccountManagerInit(WPARAM, LPARAM);
+ static int __cdecl OnAccountListChanged(void *obj, WPARAM wParam, LPARAM lParam);
static int __cdecl OnOptionsInit(void *obj, WPARAM wParam, LPARAM lParam);
- INT_PTR __cdecl OnContactDeleted(WPARAM, LPARAM);
-
static void OnFriendRequest(Tox *tox, const uint8_t *userId, const uint8_t *message, const uint16_t messageSize, void *arg);
static void OnFriendMessage(Tox *tox, const int friendnumber, const uint8_t *message, const uint16_t messageSize, void *arg);
static void OnFriendNameChange(Tox *tox, const int friendnumber, const uint8_t *name, const uint16_t nameSize, void *arg);
@@ -142,13 +143,16 @@ private: std::vector<uint8_t> HexStringToData(std::string hex);
std::string DataToHexString(std::vector<uint8_t>);
- std::string GetToxProfilePath();
+ static bool IsFileExists(std::tstring path);
+
+ std::tstring GetToxProfilePath();
int LoadToxData();
int SaveToxData();
// dialogs
static INT_PTR CALLBACK MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
+ static INT_PTR CALLBACK ToxProfileManagerProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
};
#endif //_TOX_PROTO_H_
\ No newline at end of file diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp index 7c321ac2c7..60dd7e6233 100644 --- a/protocols/Tox/src/tox_utils.cpp +++ b/protocols/Tox/src/tox_utils.cpp @@ -125,18 +125,31 @@ std::string CToxProto::DataToHexString(std::vector<uint8_t> data) return oss.str();
}
-std::string CToxProto::GetToxProfilePath()
+bool CToxProto::IsFileExists(std::tstring path)
{
- std::string profilePath;
- ptrA path(getStringA("DataPath"));
- if (path)
+ //return ::GetFileAttributes(fileName) != DWORD(-1)
+ WIN32_FIND_DATA wfd;
+ HANDLE hFind = FindFirstFile(path.c_str(), &wfd);
+ if (INVALID_HANDLE_VALUE != hFind)
{
- profilePath = path;
+ FindClose(hFind);
+ return true;
}
- if (profilePath.empty())
+ return false;
+}
+
+std::tstring CToxProto::GetToxProfilePath()
+{
+ std::tstring profilePath;
+ //ptrA path(getStringA("DataPath"));
+ //if (path)
+ //{
+ // profilePath = path;
+ //}
+ //if (profilePath.empty())
{
- char defaultPath[MAX_PATH];
- mir_snprintf(defaultPath, MAX_PATH, "%s\\%s.tox", VARS("%miranda_userdata%"), _T2A(m_tszUserName));
+ TCHAR defaultPath[MAX_PATH];
+ mir_sntprintf(defaultPath, MAX_PATH, _T("%s\\%s.tox"), VARST(_T("%miranda_userdata%")), m_tszUserName);
profilePath = defaultPath;
}
return profilePath;
@@ -144,9 +157,8 @@ std::string CToxProto::GetToxProfilePath() int CToxProto::LoadToxData()
{
- std::string toxProfilePath = GetToxProfilePath();
- FILE *hFile = fopen(toxProfilePath.c_str(), "rb");
-
+ std::tstring toxProfilePath = GetToxProfilePath();
+ FILE *hFile = _wfopen(toxProfilePath.c_str(), _T("rb"));
if (hFile)
{
fseek(hFile, 0, SEEK_END);
@@ -182,14 +194,8 @@ int CToxProto::LoadToxData() int CToxProto::SaveToxData()
{
- ptrA path(getStringA("DataPath"));
- if (!path)
- {
- return 0;
- }
-
- FILE *hFile = fopen(path, "wb");
-
+ std::tstring toxProfilePath = GetToxProfilePath();
+ FILE *hFile = _wfopen(toxProfilePath.c_str(), _T("wb"));
if (!hFile)
{
//perror("[!] load_key");
|