diff options
Diffstat (limited to 'protocols/Tox')
-rw-r--r-- | protocols/Tox/res/resource.rc | 8 | ||||
-rw-r--r-- | protocols/Tox/src/common.h | 1 | ||||
-rw-r--r-- | protocols/Tox/src/resource.h | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_accounts.cpp | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_options.cpp | 16 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_utils.cpp | 12 |
7 files changed, 37 insertions, 9 deletions
diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc index 51aa28ba0b..581e186747 100644 --- a/protocols/Tox/res/resource.rc +++ b/protocols/Tox/res/resource.rc @@ -91,6 +91,8 @@ BEGIN LTEXT "Default group:",IDC_STATIC,12,40,54,12
EDITTEXT IDC_GROUP,66,39,120,12,ES_AUTOHSCROLL
PUSHBUTTON "C",IDC_CLIPBOARD,170,22,16,13
+ LTEXT "Password:",IDC_STATIC,12,56,35,8
+ EDITTEXT IDC_PASSWORD,67,54,119,14,ES_PASSWORD | ES_AUTOHSCROLL
END
IDD_OPTIONS_MAIN DIALOGEX 0, 0, 312, 234
@@ -102,14 +104,16 @@ BEGIN EDITTEXT IDC_NAME,81,19,219,12,ES_AUTOHSCROLL
LTEXT "Tox ID:",IDC_STATIC,12,36,61,12
EDITTEXT IDC_TOXID,81,35,199,12,ES_AUTOHSCROLL | ES_READONLY
- GROUPBOX "Connection settings",IDC_STATIC,7,85,298,49
+ GROUPBOX "Connection settings",IDC_STATIC,7,89,298,45
CONTROL "Disable UDP (force Tox to use TCP)",IDC_DISABLE_UDP,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,101,288,10
CONTROL "Disable IPv6",IDC_DISABLE_IPV6,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,116,288,10
- GROUPBOX "Tox",IDC_STATIC,7,7,298,67
+ GROUPBOX "Tox",IDC_STATIC,7,7,298,77
LTEXT "Default group:",IDC_STATIC,12,53,60,12
EDITTEXT IDC_GROUP,81,51,219,12,ES_AUTOHSCROLL
PUSHBUTTON "C",IDC_CLIPBOARD,284,35,16,13
+ LTEXT "Passowrd:",IDC_STATIC,12,68,35,8
+ EDITTEXT IDC_PASSWORD,81,66,219,14,ES_PASSWORD | ES_AUTOHSCROLL
END
IDD_PROFILE_MANAGER DIALOGEX 0, 0, 235, 111
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)
{
|