diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2014-08-17 17:26:18 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2014-08-17 17:26:18 +0000 |
commit | bf23720e7c1d7de70d7d99167a42783f08ef8b17 (patch) | |
tree | aa89f34bb46da1f7f66062d6f25a4ac2a103cb9b /protocols/Tox/src/tox_utils.cpp | |
parent | a9276f9db53affa2acbd8bc3f435285c1b838f87 (diff) |
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
Diffstat (limited to 'protocols/Tox/src/tox_utils.cpp')
-rw-r--r-- | protocols/Tox/src/tox_utils.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
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<uint8_t> CToxProto::HexStringToData(std::string hex) std::string CToxProto::DataToHexString(std::vector<uint8_t> 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<int>(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)
{
|