diff options
Diffstat (limited to 'protocols/Tox/src/tox_utils.cpp')
-rw-r--r-- | protocols/Tox/src/tox_utils.cpp | 89 |
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);
-}
|