blob: d26d86f6c33520014dc7729cf978f3e238ff6e54 [file] [log] [blame]
Constantin Kaplinsky7f8d7742006-05-11 05:29:14 +00001/* Copyright (C) 2004-2005 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19#include <vncconfig/resource.h>
20#include <vncconfig/PasswordDialog.h>
21#include <rfb_win32/MsgBox.h>
22#include <rfb/Password.h>
23
24using namespace rfb;
25using namespace win32;
26
27PasswordDialog::PasswordDialog(const RegKey& rk, bool registryInsecure_)
28 : Dialog(GetModuleHandle(0)), regKey(rk), registryInsecure(registryInsecure_) {
29}
30
31bool PasswordDialog::showDialog(HWND owner) {
32 return Dialog::showDialog(MAKEINTRESOURCE(IDD_AUTH_VNC_PASSWD), owner);
33}
34
35bool PasswordDialog::onOk() {
36 TPlainPasswd password1(getItemString(IDC_PASSWORD1));
37 TPlainPasswd password2(getItemString(IDC_PASSWORD2));
38 if (_tcscmp(password1.buf, password2.buf) != 0) {
39 MsgBox(0, _T("The supplied passwords do not match"),
40 MB_ICONEXCLAMATION | MB_OK);
41 return false;
42 }
43 if (registryInsecure &&
44 (MsgBox(0, _T("Please note that your password cannot be stored securely on this system. ")
45 _T("Are you sure you wish to continue?"),
46 MB_YESNO | MB_ICONWARNING) == IDNO))
47 return false;
48 PlainPasswd password(strDup(password1.buf));
49 ObfuscatedPasswd obfPwd(password);
50 regKey.setBinary(_T("Password"), obfPwd.buf, obfPwd.length);
51 return true;
52}