1 |
/* wptPreferencesDlg.cpp - Dialog for the preferences |
/* wptPreferencesDlg.cpp - Dialog for the preferences |
2 |
* Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz |
* Copyright (C) 2001, 2002, 2003, 2005, 2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
17 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
*/ |
|
|
|
20 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
21 |
#include <config.h> |
#include <config.h> |
22 |
#endif |
#endif |
23 |
|
|
24 |
#include <windows.h> |
#include <windows.h> |
|
#include <windows.h> |
|
25 |
#include <shlobj.h> |
#include <shlobj.h> |
26 |
|
|
27 |
#include "wptNLS.h" |
#include "wptNLS.h" |
36 |
#include "wptVersion.h" |
#include "wptVersion.h" |
37 |
#include "wptAgent.h" |
#include "wptAgent.h" |
38 |
#include "wptKeyserver.h" |
#include "wptKeyserver.h" |
39 |
#include "../resource.h" |
#include "resource.h" |
40 |
|
|
41 |
|
|
42 |
/* Dialog IDs of all hotkeys. */ |
/* Dialog IDs of all hotkeys. */ |
43 |
static int hotkeys[] = { |
static int hotkeys[] = { |
44 |
IDC_PREFS_CLIP_ENCRYPT, |
IDC_PREFS_CLIP_ENCRYPT, |
45 |
IDC_PREFS_CLIP_DECRYPT_VERIFY, |
IDC_PREFS_CLIP_DECRYPT_VERIFY, |
|
IDC_PREFS_CLIP_SIGN, |
|
46 |
IDC_PREFS_CLIP_SIGNENC, |
IDC_PREFS_CLIP_SIGNENC, |
47 |
|
IDC_PREFS_CLIP_SIGN, |
48 |
IDC_PREFS_CWS_ENCRYPT, |
IDC_PREFS_CWS_ENCRYPT, |
49 |
IDC_PREFS_CWS_DECRYPT_VERIFY, |
IDC_PREFS_CWS_DECRYPT_VERIFY, |
50 |
IDC_PREFS_CWS_SIGN, |
IDC_PREFS_CWS_SIGN, |
55 |
|
|
56 |
/* Check that the given hotkey is in A..Z or a..z. */ |
/* Check that the given hotkey is in A..Z or a..z. */ |
57 |
static int |
static int |
58 |
check_hotkey (char * key) |
check_hotkey (char *key) |
59 |
{ |
{ |
60 |
if (*key >= 'A' && *key <= 'Z') |
if (*key >= 'A' && *key <= 'Z') |
61 |
return 1; |
return 1; |
93 |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), mode); |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), mode); |
94 |
} |
} |
95 |
|
|
96 |
|
/* Helper function to prepare dialog. */ |
|
/* Initialize the combox in the dialog @dlg with the valid list modes. */ |
|
97 |
static void |
static void |
98 |
init_keylist_modes (HWND dlg) |
on_init_dialog (HWND dlg) |
99 |
{ |
{ |
100 |
HWND cb = GetDlgItem (dlg, IDC_PREFS_LISTMODE); |
struct gettext_tab_s prefs[] = { |
101 |
combox_add_string (cb, (char *)"NORMAL"); |
{IDC_PREFS_SECMODE, _("Do not use any &temporary files")}, |
102 |
combox_add_string (cb, (char *)"MINIMAL"); |
{IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext")}, |
103 |
SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.keylist_mode, 0); |
{IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column")}, |
104 |
} |
{IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)")}, |
105 |
|
{IDC_PREFS_TRUST, _("Skip key validation and assume that keys are always fully trusted")}, |
106 |
|
{IDC_PREFS_AUTOBACKUP, _("&Automatic keyring backup when WinPT closes")}, |
107 |
|
{IDC_PREFS_BAKHOME, _("Backup to &keyring folder")}, |
108 |
|
{IDC_PREFS_BAKUSER, _("Backup to:")}, |
109 |
|
{IDC_PREFS_KEYLISTINF, _("Select &key list mode")}, |
110 |
|
{IDC_PREFS_KSINF, _("Keyserver &config")}, |
111 |
|
{IDC_PREFS_CACHEINF, _("Cache &passphrases for 'n' minutes")}, |
112 |
|
{IDC_PREFS_CACHEHINT, _("(CTRL+ALT+F to clear the cache)")}, |
113 |
|
{IDC_PREFS_ALLOPTINF, _("General options")}, |
114 |
|
{IDC_PREFS_CLIPINF, _("Clipboard hotkeys")}, |
115 |
|
{IDC_PREFS_CURRINF, _("Current window hotkeys")}, |
116 |
|
{IDC_PREFS_KSELFILE, _("Browse...")}, |
117 |
|
{IDC_PREFS_BAKSELECT, _("Browse...")}, |
118 |
|
{IDC_PREFS_EXTINF, _("Default extension for encrypted files")}, |
119 |
|
{IDC_PREFS_BAKSECRING, _("&Backup includes secret keyring")}, |
120 |
|
{IDCANCEL, _("&Cancel")}, |
121 |
|
{0, NULL}}; |
122 |
|
int i; |
123 |
|
HWND cb; |
124 |
|
|
125 |
|
gettext_localize_dialog (dlg, prefs, _("WinPT Preferences")); |
126 |
|
|
127 |
/* Initialize the combobox in the dialog @dlg with the valid wipe modes. */ |
SetDlgItemInt (dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time/60, TRUE); |
128 |
static void |
SetDlgItemInt (dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE); |
129 |
init_wipe_modes (HWND dlg) |
if (reg_prefs.backup.path) |
130 |
{ |
SetDlgItemText (dlg, IDC_PREFS_BAKPATH, reg_prefs.backup.path); |
131 |
HWND cb = GetDlgItem (dlg, IDC_PREFS_WIPEMODE); |
|
132 |
combox_add_string (cb, (char *)"Simple"); |
for (i=0; hotkeys[i]; i++) { |
133 |
combox_add_string (cb, (char *)"DoD"); |
if (!wpt_hotkeys[i].enabled) |
134 |
combox_add_string (cb, (char *)"Gutmann"); |
continue; |
135 |
SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.wipe_mode, 0); |
char key[2]; |
136 |
|
key[0] = wpt_hotkeys[i].key; |
137 |
|
key[1] = 0; |
138 |
|
SetDlgItemText (dlg, hotkeys[i], key); |
139 |
|
} |
140 |
|
cb = GetDlgItem (dlg, IDC_PREFS_DEFEXT); |
141 |
|
combox_add_string (cb, "GnuPG (.gpg)"); |
142 |
|
combox_add_string (cb, "PGP (.pgp)"); |
143 |
|
SendMessage (cb, CB_SETCURSEL, 0, 0); |
144 |
|
|
145 |
|
CheckDlgButton (dlg, IDC_PREFS_DISABLE_HOTKEYS, |
146 |
|
reg_prefs.no_hotkeys ? BST_CHECKED : BST_UNCHECKED); |
147 |
|
CheckDlgButton (dlg, IDC_PREFS_VIEWER, |
148 |
|
reg_prefs.use_viewer ? BST_CHECKED: BST_UNCHECKED); |
149 |
|
CheckDlgButton (dlg, IDC_PREFS_TRUST, |
150 |
|
reg_prefs.always_trust? BST_CHECKED : BST_UNCHECKED); |
151 |
|
CheckDlgButton (dlg, IDC_PREFS_AUTOBACKUP, |
152 |
|
reg_prefs.auto_backup? BST_CHECKED : BST_UNCHECKED); |
153 |
|
CheckDlgButton (dlg, IDC_PREFS_BAKHOME, |
154 |
|
reg_prefs.backup.mode==1? BST_CHECKED : BST_UNCHECKED); |
155 |
|
CheckDlgButton (dlg, IDC_PREFS_BAKUSER, |
156 |
|
reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED); |
157 |
|
CheckDlgButton (dlg, IDC_PREFS_BAKSECRING, |
158 |
|
reg_prefs.backup.include_secr? BST_CHECKED :BST_UNCHECKED); |
159 |
|
SendDlgItemMessage (dlg, IDC_PREFS_DEFEXT, CB_SETCURSEL, |
160 |
|
reg_prefs.default_ext, 0); |
161 |
|
if (reg_prefs.no_hotkeys) |
162 |
|
disable_hotkey_items (dlg, 1); |
163 |
|
if (!reg_prefs.auto_backup) |
164 |
|
enable_backup_items (dlg, 0); |
165 |
|
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), |
166 |
|
reg_prefs.backup.mode==1?FALSE : TRUE); |
167 |
|
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), |
168 |
|
reg_prefs.backup.mode==1? FALSE : TRUE); |
169 |
|
center_window (dlg, NULL); |
170 |
|
SetForegroundWindow (dlg); |
171 |
} |
} |
172 |
|
|
173 |
|
|
176 |
prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
177 |
{ |
{ |
178 |
int rc; |
int rc; |
179 |
int i, id; |
int i; |
180 |
char t[2]; |
char t[3]; |
181 |
char path[256], * p; |
char path[256], *p; |
|
HWND cb; |
|
182 |
|
|
183 |
switch ( msg ) { |
switch (msg) { |
184 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
185 |
#ifndef LANG_DE |
on_init_dialog (dlg); |
|
SetWindowText (dlg, _("WinPT Preferences")); |
|
|
SetDlgItemText (dlg, IDC_PREFS_SECMODE, _("Do not use any &temporary files")); |
|
|
SetDlgItemText (dlg, IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext")); |
|
|
SetDlgItemText (dlg, IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column")); |
|
|
SetDlgItemText (dlg, IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)")); |
|
|
SetDlgItemText (dlg, IDC_PREFS_TRUST, _("Skip key validation and assume that keys are always fully trusted")); |
|
|
SetDlgItemText (dlg, IDC_PREFS_AUTOBACKUP, _("&Automatic keyring backup when WinPT closes")); |
|
|
SetDlgItemText (dlg, IDC_PREFS_BAKHOME, _("Backup to GPG &home folder")); |
|
|
SetDlgItemText (dlg, IDC_PREFS_BAKUSER, _("Backup to:")); |
|
|
#endif |
|
|
SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE ); |
|
|
SetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE ); |
|
|
if (reg_prefs.backup.path) |
|
|
SetDlgItemText (dlg, IDC_PREFS_BAKPATH, reg_prefs.backup.path); |
|
|
if (reg_prefs.kserv_conf) |
|
|
SetDlgItemText (dlg, IDC_PREFS_KSERVER, reg_prefs.kserv_conf); |
|
|
|
|
|
for (i=0; (id=hotkeys[i]); i++) |
|
|
SetDlgItemText (dlg, id, reg_hotkeys[i].key); |
|
|
CheckDlgButton( dlg, IDC_PREFS_DISABLE_HOTKEYS, |
|
|
reg_prefs.no_hotkeys ? BST_CHECKED : BST_UNCHECKED ); |
|
|
CheckDlgButton( dlg, IDC_PREFS_SECMODE, |
|
|
reg_prefs.use_tmpfiles ? BST_UNCHECKED : BST_CHECKED ); |
|
|
CheckDlgButton( dlg, IDC_PREFS_VIEWER, |
|
|
reg_prefs.use_viewer ? BST_CHECKED: BST_UNCHECKED ); |
|
|
CheckDlgButton( dlg, IDC_PREFS_TRUST, |
|
|
reg_prefs.always_trust? BST_CHECKED : BST_UNCHECKED ); |
|
|
CheckDlgButton( dlg, IDC_PREFS_AUTOBACKUP, |
|
|
reg_prefs.auto_backup? BST_CHECKED : BST_UNCHECKED ); |
|
|
CheckDlgButton( dlg, IDC_PREFS_BAKHOME, |
|
|
reg_prefs.backup.mode==1? BST_CHECKED : BST_UNCHECKED ); |
|
|
CheckDlgButton( dlg, IDC_PREFS_BAKUSER, |
|
|
reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED ); |
|
|
if( reg_prefs.no_hotkeys ) |
|
|
disable_hotkey_items( dlg, 1 ); |
|
|
if (!reg_prefs.auto_backup) |
|
|
enable_backup_items (dlg, 0); |
|
|
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), |
|
|
reg_prefs.backup.mode==1?FALSE : TRUE); |
|
|
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), |
|
|
reg_prefs.backup.mode==1? FALSE : TRUE); |
|
|
init_keylist_modes (dlg); |
|
|
init_wipe_modes (dlg); |
|
|
center_window (dlg, NULL); |
|
|
SetForegroundWindow (dlg); |
|
186 |
return TRUE; |
return TRUE; |
187 |
|
|
188 |
case WM_SYSCOMMAND: |
case WM_SYSCOMMAND: |
189 |
if (LOWORD (wparam) == SC_CLOSE) |
if (LOWORD (wparam) == SC_CLOSE) |
190 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, FALSE); |
191 |
return FALSE; |
return FALSE; |
192 |
|
|
193 |
case WM_COMMAND: |
case WM_COMMAND: |
194 |
switch( HIWORD(wparam) ) { |
switch (HIWORD (wparam)) { |
195 |
case BN_CLICKED: |
case BN_CLICKED: |
196 |
switch( (int)LOWORD( wparam ) ) { |
switch ((int)LOWORD (wparam)) { |
197 |
case IDC_PREFS_DISABLE_HOTKEYS: |
case IDC_PREFS_DISABLE_HOTKEYS: |
198 |
reg_prefs.no_hotkeys ^= 1; |
reg_prefs.no_hotkeys ^= 1; |
199 |
disable_hotkey_items( dlg, reg_prefs.no_hotkeys ); |
disable_hotkey_items (dlg, reg_prefs.no_hotkeys); |
200 |
break; |
break; |
201 |
|
|
202 |
case IDC_PREFS_TRUST: |
case IDC_PREFS_TRUST: |
203 |
reg_prefs.always_trust ^= 1; |
reg_prefs.always_trust ^= 1; |
204 |
if( reg_prefs.always_trust ) { |
if (reg_prefs.always_trust) { |
205 |
msg_box (dlg, |
msg_box (dlg, |
206 |
_("In most cases it is not a good idea to enable this setting.\n" |
_("In most cases it is not a good idea to enable this setting.\n" |
207 |
"If you know what you are doing let this flag enabled, otherwise\n" |
"If you know what you are doing, you can enable this flag, otherwise\n" |
208 |
"it is safe to leave this flag untouched."), |
"it is safe to leave this flag untouched."), |
209 |
_("Preferences"), MB_ICONWARNING|MB_OK ); |
_("Preferences"), MB_ICONWARNING|MB_OK); |
210 |
} |
} |
211 |
break; |
break; |
212 |
|
|
218 |
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER)) |
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER)) |
219 |
CheckDlgButton (dlg, IDC_PREFS_BAKHOME, BST_CHECKED); |
CheckDlgButton (dlg, IDC_PREFS_BAKHOME, BST_CHECKED); |
220 |
} |
} |
221 |
|
if (IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME)) |
222 |
|
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), FALSE); |
223 |
break; |
break; |
224 |
|
|
225 |
case IDC_PREFS_BAKHOME: |
case IDC_PREFS_BAKHOME: |
234 |
} |
} |
235 |
break; |
break; |
236 |
} |
} |
237 |
switch( LOWORD( wparam ) ) { |
switch (LOWORD (wparam)) { |
238 |
case IDC_PREFS_BAKSELECT: |
case IDC_PREFS_BAKSELECT: |
239 |
const char *bpath; |
const char *bpath; |
240 |
bpath = get_folder_dlg (dlg, _("Select GPG backup path"), NULL); |
bpath = get_folder_dlg (dlg, _("Select GPG backup path"), NULL); |
242 |
SetDlgItemText (dlg, IDC_PREFS_BAKPATH, bpath); |
SetDlgItemText (dlg, IDC_PREFS_BAKPATH, bpath); |
243 |
break; |
break; |
244 |
|
|
|
case IDC_PREFS_KSELFILE: { |
|
|
const char * name; |
|
|
name = get_filename_dlg (dlg, FILE_OPEN, _("Please select a keyserver.conf file"), |
|
|
NULL, NULL); |
|
|
if (name != NULL) |
|
|
SetDlgItemText (dlg, IDC_PREFS_KSERVER, name); |
|
|
break; } |
|
|
|
|
245 |
case IDOK: |
case IDOK: |
246 |
rc = GetDlgItemInt( dlg, IDC_PREFS_CACHETIME, NULL, FALSE ); |
rc = GetDlgItemInt (dlg, IDC_PREFS_CACHETIME, NULL, FALSE); |
247 |
if( !rc ) |
if (rc <= 0) { |
248 |
reg_prefs.cache_time = 0; |
reg_prefs.cache_time = 0; |
249 |
else if( rc > 3600 ) { |
agent_flush_cache (); |
250 |
msg_box( dlg, _("Please enter a value that is between 1-3600.\nIt is not " |
} |
251 |
"a good idea to cache the passphrase more than one hour."), |
else if (rc > 720) { |
252 |
_("Preferences"), MB_ERR ); |
msg_box( dlg, _("Please enter a value that is between 1-720.\nIt is not " |
253 |
SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, 0, FALSE ); |
"a good idea to cache the passphrase more than 12 hours."), |
254 |
|
_("Preferences"), MB_ERR); |
255 |
|
SetDlgItemInt (dlg, IDC_PREFS_CACHETIME, 0, FALSE); |
256 |
return TRUE; |
return TRUE; |
257 |
} |
} |
258 |
if (reg_prefs.cache_time != rc) |
if (reg_prefs.cache_time != rc) |
259 |
agent_flush_cache (); |
agent_flush_cache (); |
260 |
reg_prefs.cache_time = rc; |
reg_prefs.cache_time = rc*60; |
261 |
rc = GetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, NULL, FALSE ); |
rc = GetDlgItemInt (dlg, IDC_PREFS_WORDWRAP, NULL, FALSE); |
262 |
if( !rc ) |
if (rc <= 0) |
263 |
reg_prefs.word_wrap = 0; |
reg_prefs.word_wrap = 0; |
264 |
else if( rc > 80 ) { |
else if (rc > 80) { |
265 |
msg_box( dlg, _("Please enter a value between 1-80."), _("Preferences"), MB_ERR ); |
msg_box (dlg, _("Please enter a value between 1-80."), |
266 |
|
_("Preferences"), MB_ERR); |
267 |
return TRUE; |
return TRUE; |
268 |
} |
} |
269 |
|
reg_prefs.default_ext = SendDlgItemMessage (dlg, IDC_PREFS_DEFEXT, CB_GETCURSEL, 0, 0); |
270 |
reg_prefs.word_wrap = rc; |
reg_prefs.word_wrap = rc; |
271 |
reg_prefs.use_tmpfiles = IsDlgButtonChecked( dlg, IDC_PREFS_SECMODE )? 0 : 1; |
reg_prefs.use_viewer = IsDlgButtonChecked (dlg, IDC_PREFS_VIEWER)? 1 : 0; |
272 |
reg_prefs.use_viewer = IsDlgButtonChecked( dlg, IDC_PREFS_VIEWER )? 1 : 0; |
reg_prefs.backup.mode = IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME ) ? 1 : |
273 |
reg_prefs.backup.mode = IsDlgButtonChecked( dlg, IDC_PREFS_BAKHOME ) ? 1 : |
IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER)? 2 : 0; |
274 |
IsDlgButtonChecked( dlg, IDC_PREFS_BAKUSER )? 2 : 0; |
reg_prefs.backup.include_secr = IsDlgButtonChecked (dlg, IDC_PREFS_BAKSECRING)? 1 : 0; |
275 |
if( reg_prefs.backup.mode == 2 ) { |
#ifdef WINPT_MOBILE |
276 |
if( !GetDlgItemText( dlg, IDC_PREFS_BAKPATH, path, sizeof (path)-1 ) |
/* We cannot allow backups to a specific path outside |
277 |
|| dir_exist_check( path ) ) { |
the USB disk, so we disable it. */ |
278 |
msg_box( dlg, _("The specified backup folder is invalid."), |
if (reg_prefs.backup.mode == 2) { |
279 |
_("Preferences"), MB_ERR ); |
reg_prefs.backup.mode = 1; |
280 |
|
reg_prefs.backup.include_secr = 0; |
281 |
|
} |
282 |
|
#endif |
283 |
|
if (reg_prefs.backup.mode == 2) { |
284 |
|
if (!GetDlgItemText (dlg, IDC_PREFS_BAKPATH, path, sizeof (path)-1) |
285 |
|
|| dir_exist_check (path)) { |
286 |
|
msg_box (dlg, _("The specified backup folder is invalid."), |
287 |
|
_("Preferences"), MB_ERR); |
288 |
return TRUE; |
return TRUE; |
289 |
} |
} |
290 |
free_if_alloc (reg_prefs.backup.path); |
free_if_alloc (reg_prefs.backup.path); |
292 |
if (!p) |
if (!p) |
293 |
BUG (0); |
BUG (0); |
294 |
} |
} |
|
free_if_alloc (reg_prefs.kserv_conf); |
|
|
if (!GetDlgItemText (dlg, IDC_PREFS_KSERVER, path, sizeof (path)-1) |
|
|
|| file_exist_check (path)) { |
|
|
rc = msg_box (dlg, _("The specified keyserver config file is invalid.\n\n" |
|
|
"Create new default config file?"), |
|
|
_("Preferences"), MB_ERR|MB_YESNO); |
|
|
if (rc == IDNO) |
|
|
return TRUE; |
|
|
else |
|
|
{ |
|
|
char cwd[256], * fn; |
|
|
FILE * fp = fopen ("keyserver.conf", "wb"); |
|
|
if (fp) { |
|
|
fprintf (fp, "%s\r\n", DEF_HKP_KEYSERVER); |
|
|
fclose (fp); |
|
|
} |
|
|
GetCurrentDirectory (DIM (cwd)-1, cwd); |
|
|
fn = make_filename (cwd, "keyserver", "conf"); |
|
|
memset (path, 0, sizeof( path)); |
|
|
strncpy (path, fn, DIM (path)-1); |
|
|
free_if_alloc (fn); |
|
|
} |
|
|
} |
|
|
p = reg_prefs.kserv_conf = m_strdup (path); |
|
|
if (!p) |
|
|
BUG (0); |
|
|
|
|
|
cb = GetDlgItem( dlg, IDC_PREFS_LISTMODE ); |
|
|
reg_prefs.keylist_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 ); |
|
|
|
|
|
cb = GetDlgItem( dlg, IDC_PREFS_WIPEMODE ); |
|
|
reg_prefs.wipe_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 ); |
|
295 |
|
|
296 |
if (IsDlgButtonChecked (dlg, IDC_PREFS_DISABLE_HOTKEYS)) { |
if (IsDlgButtonChecked (dlg, IDC_PREFS_DISABLE_HOTKEYS)) { |
297 |
hotkeys_unregister (glob_hwnd); |
hotkeys_unregister (glob_hwnd); |
299 |
} |
} |
300 |
else { |
else { |
301 |
reg_prefs.no_hotkeys = 0; |
reg_prefs.no_hotkeys = 0; |
302 |
for( i = 0; (id = hotkeys[i]); i++ ) { |
for (i = 0; hotkeys[i]; i++) { |
303 |
rc = GetDlgItemText( dlg, id, t, 2 ); |
rc = GetDlgItemText (dlg, hotkeys[i], t, sizeof (t)-1); |
304 |
if( rc && check_hotkey( &t[0] ) ) |
if (rc > 0 && check_hotkey (&t[0])) |
305 |
hotkey_enable( ®_hotkeys[i], t ); |
hotkey_enable (&wpt_hotkeys[i], t); |
306 |
else |
else |
307 |
hotkey_disable( ®_hotkeys[i] ); |
hotkey_disable (&wpt_hotkeys[i]); |
308 |
} |
} |
309 |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "DisableHotkeys", "0"); |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "DisableHotkeys", "0"); |
310 |
reg_prefs.no_hotkeys = 0; |
reg_prefs.no_hotkeys = 0; |
311 |
} |
} |
312 |
|
|
313 |
if ((rc = set_reg_winpt_prefs (®_prefs))) |
rc = set_reg_winpt_prefs (®_prefs); |
314 |
|
if (rc) |
315 |
msg_box (dlg, winpt_strerror (rc), _("Preferences"), MB_ERR); |
msg_box (dlg, winpt_strerror (rc), _("Preferences"), MB_ERR); |
316 |
|
|
317 |
if (reg_prefs.no_hotkeys == 0) { |
if (reg_prefs.no_hotkeys == 0) { |
318 |
hotkeys_unregister (glob_hwnd); |
hotkeys_unregister (glob_hwnd); |
319 |
hotkeys_modify (); |
rc = hotkeys_register (glob_hwnd); |
320 |
if ((rc = hotkeys_register (glob_hwnd))) |
if (rc) |
321 |
msg_box (NULL, winpt_strerror (rc), _("Hotkeys"), MB_ERR); |
msg_box (NULL, winpt_strerror (rc), _("Hotkeys"), MB_ERR); |
322 |
} |
} |
323 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
324 |
return TRUE; |
return TRUE; |
325 |
|
|
326 |
case IDCANCEL: |
case IDCANCEL: |
327 |
EndDialog( dlg, FALSE ); |
/* Reset backup mode if no mode was chosen. */ |
328 |
|
if (reg_prefs.auto_backup == 1 && |
329 |
|
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME) && |
330 |
|
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER)) |
331 |
|
reg_prefs.auto_backup = 0; |
332 |
|
EndDialog (dlg, FALSE); |
333 |
return FALSE; |
return FALSE; |
334 |
} |
} |
335 |
break; |
break; |