summaryrefslogtreecommitdiff
path: root/protocols/Tox/src
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2014-09-27 09:25:36 +0000
committerKirill Volinsky <mataes2007@gmail.com>2014-09-27 09:25:36 +0000
commit93467b8c3702be5fc9f9b60c3ff6863cb37ccd8d (patch)
tree23659d34af33a062ba60bd7cc5dcd176f3f23b3a /protocols/Tox/src
parente02a45507e91d072b86f26f36dbebf655ad9d79f (diff)
encrypt tox profile (dont't work, crashed on tox_encrypted_load)
git-svn-id: http://svn.miranda-ng.org/main/trunk@10612 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r--protocols/Tox/src/common.h1
-rw-r--r--protocols/Tox/src/resource.h3
-rw-r--r--protocols/Tox/src/tox_accounts.cpp3
-rw-r--r--protocols/Tox/src/tox_options.cpp16
-rw-r--r--protocols/Tox/src/tox_proto.cpp3
-rw-r--r--protocols/Tox/src/tox_utils.cpp12
6 files changed, 31 insertions, 7 deletions
diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h
index fb36ce1557..d28a9f1495 100644
--- a/protocols/Tox/src/common.h
+++ b/protocols/Tox/src/common.h
@@ -33,6 +33,7 @@
#include <tox.h>
#include <toxdns.h>
+#include <toxencryptsave.h>
#include "version.h"
#include "resource.h"
diff --git a/protocols/Tox/src/resource.h b/protocols/Tox/src/resource.h
index d60361a5ea..a59da4ee67 100644
--- a/protocols/Tox/src/resource.h
+++ b/protocols/Tox/src/resource.h
@@ -11,6 +11,7 @@
#define IDC_CREATE_NEW 1006
#define IDC_PROFILE_PATH 1007
#define IDC_SEARCH 1008
+#define IDC_PASSWORD 1008
#define IDC_USE_EXISTING 1009
#define IDC_BROWSE_PROFILE 1010
#define IDC_NAME 1011
@@ -25,7 +26,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
-#define _APS_NEXT_CONTROL_VALUE 1008
+#define _APS_NEXT_CONTROL_VALUE 1016
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
diff --git a/protocols/Tox/src/tox_accounts.cpp b/protocols/Tox/src/tox_accounts.cpp
index 95b7284e93..acab9db206 100644
--- a/protocols/Tox/src/tox_accounts.cpp
+++ b/protocols/Tox/src/tox_accounts.cpp
@@ -32,7 +32,8 @@ int CToxProto::OnAccountListChanged(WPARAM wParam, LPARAM lParam)
switch (wParam)
{
case PRAC_ADDED:
- UninitToxCore();
+ if (this->getStringA("ToxID"))
+ UninitToxCore();
DialogBoxParam(
g_hInstance,
MAKEINTRESOURCE(IDD_PROFILE_MANAGER),
diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp
index f137c8e738..d811569175 100644
--- a/protocols/Tox/src/tox_options.cpp
+++ b/protocols/Tox/src/tox_options.cpp
@@ -15,6 +15,9 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
ptrW nick(proto->getTStringA("Nick"));
SetDlgItemText(hwnd, IDC_NAME, nick);
+ ptrW pass(proto->getTStringA("Password"));
+ SetDlgItemText(hwnd, IDC_PASSWORD, pass);
+
std::string address = proto->getStringA(NULL, TOX_SETTINGS_ID);
SetDlgItemTextA(hwnd, IDC_TOXID, address.c_str());
@@ -39,6 +42,14 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
}
break;
+ case IDC_PASSWORD:
+ if ((HWND)lParam == GetFocus())
+ {
+ if (HIWORD(wParam) != EN_CHANGE) return 0;
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ }
+ break;
+
case IDC_CLIPBOARD:
{
char toxId[TOX_FRIEND_ADDRESS_SIZE * 2 + 1];
@@ -75,10 +86,13 @@ INT_PTR CToxProto::MainOptionsProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
case WM_NOTIFY:
if (reinterpret_cast<NMHDR*>(lParam)->code == PSN_APPLY)
{
- TCHAR nick[TOX_MAX_NAME_LENGTH];
+ TCHAR nick[TOX_MAX_NAME_LENGTH], pass[MAX_PATH];
GetDlgItemText(hwnd, IDC_NAME, nick, TOX_MAX_NAME_LENGTH);
proto->setTString("Nick", nick);
+ GetDlgItemText(hwnd, IDC_PASSWORD, pass, SIZEOF(pass));
+ proto->setTString("Password", pass);
+
proto->setByte("DisableUDP", (BYTE)IsDlgButtonChecked(hwnd, IDC_DISABLE_UDP));
proto->setByte("DisableIPv6", (BYTE)IsDlgButtonChecked(hwnd, IDC_DISABLE_IPV6));
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp
index 3016a400ee..0d3ab920f6 100644
--- a/protocols/Tox/src/tox_proto.cpp
+++ b/protocols/Tox/src/tox_proto.cpp
@@ -5,7 +5,8 @@ PROTO<CToxProto>(protoName, userName)
{
accountName = mir_tstrdup(userName);
- InitToxCore();
+ if (this->getStringA("ToxID"))
+ InitToxCore();
CreateProtoService(PS_CREATEACCMGRUI, &CToxProto::OnAccountManagerInit);
diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp
index 47759ffd5c..2b2d5daa75 100644
--- a/protocols/Tox/src/tox_utils.cpp
+++ b/protocols/Tox/src/tox_utils.cpp
@@ -155,7 +155,12 @@ void CToxProto::LoadToxData()
return;
}
- tox_load(tox, data, size);
+ if (tox_is_data_encrypted(data)) {
+ ptrA password(mir_utf8encodeW(ptrT(getTStringA("Password"))));
+ tox_encrypted_load(tox, data, size, (uint8_t*)(char*)password, strlen(password));
+ }
+ else
+ tox_load(tox, data, size);
mir_free(data);
fclose(hFile);
@@ -171,9 +176,10 @@ void CToxProto::SaveToxData()
return;
}
- uint32_t size = tox_size(tox);
+ uint32_t size = tox_encrypted_size(tox);
uint8_t *data = (uint8_t*)mir_alloc(size);
- tox_save(tox, data);
+ ptrA password(mir_utf8encodeW(ptrT(getTStringA("Password"))));
+ tox_encrypted_save(tox, data, (uint8_t*)(char*)password, strlen(password));
if (fwrite(data, sizeof(uint8_t), size, hFile) != size)
{