diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-04-24 10:19:38 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-04-24 10:19:38 +0000 |
commit | 8c8b40f747b52bc5c8aa796b03ac5e7a2eb23eaf (patch) | |
tree | 6dbc4fe8a22ca14ba4d6eccfc794ed40cedd2374 /protocols/Tox/src/tox_profile.cpp | |
parent | ab90002f47192dcbb88fe5926faf52299179d815 (diff) |
Tox:
- fixed profile creation logic
- enabled "export profile" button
git-svn-id: http://svn.miranda-ng.org/main/trunk@13078 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_profile.cpp')
-rw-r--r-- | protocols/Tox/src/tox_profile.cpp | 53 |
1 files changed, 27 insertions, 26 deletions
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index 5f13f07f4f..51361b4b34 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -22,36 +22,37 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) size_t size = 0;
uint8_t *data = NULL;
+
std::tstring profilePath = GetToxProfilePath();
- if (IsFileExists(profilePath))
+ if (!IsFileExists(profilePath))
+ return false;
+
+ FILE *profile = _tfopen(profilePath.c_str(), _T("rb"));
+ if (profile == NULL)
{
- FILE *profile = _tfopen(profilePath.c_str(), _T("rb"));
- if (profile == NULL)
- {
- debugLogA(__FUNCTION__": failed to open tox profile");
- return false;
- }
+ debugLogA(__FUNCTION__": failed to open tox profile");
+ return false;
+ }
- fseek(profile, 0, SEEK_END);
- size = ftell(profile);
- rewind(profile);
- if (size == 0)
- {
- fclose(profile);
- debugLogA(__FUNCTION__": tox profile is empty");
- return true;
- }
+ fseek(profile, 0, SEEK_END);
+ size = ftell(profile);
+ rewind(profile);
+ if (size == 0)
+ {
+ fclose(profile);
+ debugLogA(__FUNCTION__": tox profile is empty");
+ return true;
+ }
- data = (uint8_t*)mir_calloc(size);
- if (fread((char*)data, sizeof(char), size, profile) != size)
- {
- fclose(profile);
- debugLogA(__FUNCTION__": failed to read tox profile");
- mir_free(data);
- return false;
- }
+ data = (uint8_t*)mir_calloc(size);
+ if (fread((char*)data, sizeof(char), size, profile) != size)
+ {
fclose(profile);
+ debugLogA(__FUNCTION__": failed to read tox profile");
+ mir_free(data);
+ return false;
}
+ fclose(profile);
if (data != NULL && tox_is_data_encrypted(data))
{
@@ -146,8 +147,8 @@ INT_PTR CToxProto::OnCopyToxID(WPARAM, LPARAM) }
CToxPasswordEditor::CToxPasswordEditor(CToxProto *proto) :
- CToxDlgBase(proto, IDD_PASSWORD, false), ok(this, IDOK),
- password(this, IDC_PASSWORD), savePermanently(this, IDC_SAVEPERMANENTLY)
+CToxDlgBase(proto, IDD_PASSWORD, false), ok(this, IDOK),
+password(this, IDC_PASSWORD), savePermanently(this, IDC_SAVEPERMANENTLY)
{
ok.OnClick = Callback(this, &CToxPasswordEditor::OnOk);
}
|