From bf23720e7c1d7de70d7d99167a42783f08ef8b17 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 17 Aug 2014 17:26:18 +0000 Subject: Tox: - fixed tox id convertation - fixed tox profile load in first start - fixed polling thread git-svn-id: http://svn.miranda-ng.org/main/trunk@10215 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_utils.cpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'protocols/Tox/src/tox_utils.cpp') diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp index 9f47d67de1..71efde31d1 100644 --- a/protocols/Tox/src/tox_utils.cpp +++ b/protocols/Tox/src/tox_utils.cpp @@ -116,24 +116,36 @@ std::vector CToxProto::HexStringToData(std::string hex) std::string CToxProto::DataToHexString(std::vector data) { - std::stringstream ss; - ss << std::hex << std::uppercase; - for (uint32_t i = 0; i < data.size(); i++) + std::ostringstream oss; + oss << std::setfill('0'); + for (int i = 0; i < data.size(); i++) { - ss << (int)data[i]; + oss << std::setw(2) << std::hex << std::uppercase << static_cast(data[i]); } - return ss.str(); + return oss.str(); } -int CToxProto::LoadToxData() +std::string CToxProto::GetToxProfilePath() { + std::string profilePath; ptrA path(getStringA("DataPath")); - if (!path) + if (path) { - return 0; + profilePath = path; } + if (profilePath.empty()) + { + char defaultPath[MAX_PATH]; + mir_snprintf(defaultPath, MAX_PATH, "%s\\%s.tox", VARS("%miranda_userdata%"), _T2A(m_tszUserName)); + profilePath = defaultPath; + } + return profilePath; +} - FILE *hFile = fopen(path, "rb"); +int CToxProto::LoadToxData() +{ + std::string toxProfilePath = GetToxProfilePath(); + FILE *hFile = fopen(toxProfilePath.c_str(), "rb"); if (hFile) { -- cgit v1.2.3