summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_utils.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-09-29 17:47:24 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-09-29 17:47:24 +0000
commit6beb2d44b3ab2811417507be4c78c19626c9ee7e (patch)
tree0292dd1424658b2a34850dfaebafe2bdde36bfdc /protocols/Tox/src/tox_utils.cpp
parent8f994ff592a5501018ba601d33d59a558a2d9840 (diff)
Tox:
- profile manager is now profile import - tox profile renaming without reloading of tox core - updated tox core git-svn-id: http://svn.miranda-ng.org/main/trunk@10632 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_utils.cpp')
-rw-r--r--protocols/Tox/src/tox_utils.cpp89
1 files changed, 0 insertions, 89 deletions
diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp
index 854d59f40d..a290e6a76e 100644
--- a/protocols/Tox/src/tox_utils.cpp
+++ b/protocols/Tox/src/tox_utils.cpp
@@ -120,92 +120,3 @@ bool CToxProto::IsFileExists(std::tstring path)
}
return false;
}
-
-void CToxProto::LoadToxData()
-{
- std::tstring toxProfilePath = GetToxProfilePath();
- FILE *hFile = _wfopen(toxProfilePath.c_str(), _T("rb"));
- if (!hFile)
- {
- debugLogA("CToxProto::LoadToxData: could not open tox profile");
- return;
- }
-
- fseek(hFile, 0, SEEK_END);
- uint32_t size = ftell(hFile);
- rewind(hFile);
-
- uint8_t *data = (uint8_t*)mir_alloc(size);
- if (fread(data, sizeof(uint8_t), size, hFile) != size)
- {
- debugLogA("CToxProto::LoadToxData: could not read tox profile");
- fclose(hFile);
- mir_free(data);
- return;
- }
-
- if (tox_is_data_encrypted(data))
- {
- ptrT password(getTStringA("Password"));
- char *password_utf8 = mir_utf8encodeW(password);
- if (tox_encrypted_load(tox, data, size, (uint8_t*)password_utf8, strlen(password_utf8)) == TOX_ERROR)
- {
- debugLogA("CToxProto::LoadToxData: could not decrypt tox profile");
- }
- mir_free(password_utf8);
- }
- else
- {
- if (tox_load(tox, data, size) == TOX_ERROR)
- {
- debugLogA("CToxProto::LoadToxData: could not load tox profile");
- }
- }
-
- mir_free(data);
- fclose(hFile);
-}
-
-void CToxProto::SaveToxData()
-{
- std::tstring toxProfilePath = GetToxProfilePath();
- FILE *hFile = _wfopen(toxProfilePath.c_str(), _T("wb"));
- if (!hFile)
- {
- debugLogA("CToxProto::LoadToxData: could not open tox profile");
- return;
- }
-
- ptrT password(getTStringA("Password"));
- uint32_t size;
- if (password && _tcslen(password))
- size = tox_encrypted_size(tox);
- else
- size = tox_size(tox);
- uint8_t *data = (uint8_t*)mir_alloc(size);
- if (password && _tcslen(password))
- {
- char *password_utf8 = mir_utf8encodeW(password);
- if (tox_encrypted_save(tox, data, (uint8_t*)password_utf8, strlen(password_utf8)) == TOX_ERROR)
- {
- debugLogA("CToxProto::LoadToxData: could not encrypt tox profile");
- mir_free(password_utf8);
- mir_free(data);
- fclose(hFile);
- return;
- }
- mir_free(password_utf8);
- }
- else
- {
- tox_save(tox, data);
- }
-
- if (fwrite(data, sizeof(uint8_t), size, hFile) != size)
- {
- debugLogA("CToxProto::LoadToxData: could not write tox profile");
- }
-
- mir_free(data);
- fclose(hFile);
-}