From 6beb2d44b3ab2811417507be4c78c19626c9ee7e Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Mon, 29 Sep 2014 17:47:24 +0000 Subject: 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 --- protocols/Tox/src/tox_utils.cpp | 89 ----------------------------------------- 1 file changed, 89 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 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); -} -- cgit v1.2.3