1 |
/* wptPreferencesDlg.cpp - Dialog for the preferences |
/* wptPreferencesDlg.cpp - Dialog for the preferences |
2 |
* Copyright (C) 2001, 2002, 2003 Timo Schulz |
* Copyright (C) 2001, 2002, 2003, 2005 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
6 |
* WinPT is free software; you can redistribute it and/or modify |
* WinPT is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
* (at your option) any later version. |
10 |
* |
* |
11 |
* WinPT is distributed in the hope that it will be useful, |
* WinPT is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
* GNU General Public License for more details. |
15 |
* |
* |
16 |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
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 |
21 |
#include <windows.h> |
#include <config.h> |
22 |
#include <shlobj.h> |
#endif |
23 |
|
|
24 |
#include "wptNLS.h" |
#include <windows.h> |
25 |
#include "wptGPG.h" |
#include <shlobj.h> |
26 |
#include "wptCommonCtl.h" |
|
27 |
#include "wptDlgs.h" |
#include "wptNLS.h" |
28 |
#include "wptTypes.h" |
#include "wptGPG.h" |
29 |
#include "wptErrors.h" |
#include "wptCommonCtl.h" |
30 |
#include "wptRegistry.h" |
#include "wptDlgs.h" |
31 |
#include "wptHotkey.h" |
#include "wptTypes.h" |
32 |
#include "wptW32API.h" |
#include "wptErrors.h" |
33 |
#include "wptVersion.h" |
#include "wptRegistry.h" |
34 |
#include "wptAgent.h" |
#include "wptHotkey.h" |
35 |
#include "wptKeyserver.h" |
#include "wptW32API.h" |
36 |
#include "../resource.h" |
#include "wptVersion.h" |
37 |
|
#include "wptAgent.h" |
38 |
|
#include "wptKeyserver.h" |
39 |
static int hotkeys[] = { |
#include "resource.h" |
40 |
IDC_PREFS_CLIP_ENCRYPT, |
|
41 |
IDC_PREFS_CLIP_DECRYPT_VERIFY, |
|
42 |
IDC_PREFS_CLIP_SIGN, |
/* Dialog IDs of all hotkeys. */ |
43 |
IDC_PREFS_CLIP_SIGNENC, |
static int hotkeys[] = { |
44 |
IDC_PREFS_CWS_ENCRYPT, |
IDC_PREFS_CLIP_ENCRYPT, |
45 |
IDC_PREFS_CWS_DECRYPT_VERIFY, |
IDC_PREFS_CLIP_DECRYPT_VERIFY, |
46 |
IDC_PREFS_CWS_SIGN, |
IDC_PREFS_CLIP_SIGN, |
47 |
IDC_PREFS_CWS_SIGNENC, |
IDC_PREFS_CLIP_SIGNENC, |
48 |
0 |
IDC_PREFS_CWS_ENCRYPT, |
49 |
}; |
IDC_PREFS_CWS_DECRYPT_VERIFY, |
50 |
|
IDC_PREFS_CWS_SIGN, |
51 |
|
IDC_PREFS_CWS_SIGNENC, |
52 |
static int |
0 |
53 |
check_hotkey( char * key ) |
}; |
54 |
{ |
|
55 |
if( *key >= 'A' && *key <= 'Z' ) |
|
56 |
return 1; |
/* Check that the given hotkey is in A..Z or a..z. */ |
57 |
else if( *key >= 'a' && *key <= 'z' ) { |
static int |
58 |
*key = *key - 32; |
check_hotkey (char * key) |
59 |
return 1; |
{ |
60 |
} |
if (*key >= 'A' && *key <= 'Z') |
61 |
return 0; |
return 1; |
62 |
} /* check_hotkey */ |
else if (*key >= 'a' && *key <= 'z') { |
63 |
|
*key = *key - 32; |
64 |
|
return 1; |
65 |
static void |
} |
66 |
disable_hotkey_items( HWND dlg, int yes ) |
return 0; |
67 |
{ |
} |
68 |
int mode = yes ? FALSE : TRUE; |
|
69 |
int i, id; |
|
70 |
|
/* Disable all hotkey controls in the dialog @dlg if val is 1. */ |
71 |
for( i=0; (id = hotkeys[i]); i++ ) |
static void |
72 |
EnableWindow( GetDlgItem( dlg, id ), mode ); |
disable_hotkey_items (HWND dlg, int val) |
73 |
} /* disable_hotkey_items */ |
{ |
74 |
|
int mode = val? FALSE : TRUE; |
75 |
|
int i, id; |
76 |
static void |
|
77 |
enable_backup_items( HWND dlg, int yes ) |
for (i=0; (id = hotkeys[i]); i++) |
78 |
{ |
EnableWindow (GetDlgItem (dlg, id), mode); |
79 |
int mode = yes ? TRUE : FALSE; |
} |
80 |
|
|
81 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKHOME ), mode ); |
|
82 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKUSER ), mode ); |
|
83 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKSELECT ), mode ); |
/* En- or disable the backup items in the dialog @dlg. |
84 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKPATH ), mode ); |
If val != 0 activate them, disable them otherwise. */ |
85 |
} /* enable_backup_items */ |
static void |
86 |
|
enable_backup_items (HWND dlg, int val) |
87 |
|
{ |
88 |
static void |
int mode = val? TRUE : FALSE; |
89 |
set_keylist_mode( HWND dlg ) |
|
90 |
{ |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKHOME), mode); |
91 |
HWND cb = GetDlgItem( dlg, IDC_PREFS_LISTMODE ); |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKUSER), mode); |
92 |
combox_add_string( cb, (char *)"NORMAL" ); |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), mode); |
93 |
combox_add_string( cb, (char *)"MINIMAL" ); |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), mode); |
94 |
SendMessage( cb, CB_SETCURSEL, (WPARAM)reg_prefs.keylist_mode, 0 ); |
} |
95 |
} /* set_keylist_mode */ |
|
96 |
|
|
97 |
|
/* Initialize the combox in the dialog @dlg with the valid list modes. */ |
98 |
static void |
static void |
99 |
set_wipe_mode( HWND dlg ) |
init_keylist_modes (HWND dlg) |
100 |
{ |
{ |
101 |
HWND cb = GetDlgItem( dlg, IDC_PREFS_WIPEMODE ); |
HWND cb = GetDlgItem (dlg, IDC_PREFS_LISTMODE); |
102 |
combox_add_string( cb, (char *)"Simple" ); |
combox_add_string (cb, (char *)"NORMAL"); |
103 |
combox_add_string( cb, (char *)"DoD" ); |
combox_add_string (cb, (char *)"MINIMAL"); |
104 |
combox_add_string( cb, (char *)"Gutmann" ); |
SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.keylist_mode, 0); |
105 |
SendMessage( cb, CB_SETCURSEL, (WPARAM)reg_prefs.wipe_mode, 0 ); |
} |
106 |
} /* set_wipe_mode */ |
|
107 |
|
|
108 |
|
/* Initialize the combobox in the dialog @dlg with the valid wipe modes. */ |
109 |
BOOL CALLBACK |
static void |
110 |
prefs_dlg_proc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam ) |
init_wipe_modes (HWND dlg) |
111 |
{ |
{ |
112 |
int rc; |
HWND cb = GetDlgItem (dlg, IDC_PREFS_WIPEMODE); |
113 |
int i, id; |
combox_add_string (cb, (char *)"Simple"); |
114 |
char t[2]; |
combox_add_string (cb, (char *)"DoD"); |
115 |
char path[256], * p; |
combox_add_string (cb, (char *)"Gutmann"); |
116 |
HWND cb; |
SendMessage (cb, CB_SETCURSEL, (WPARAM)reg_prefs.wipe_mode, 0); |
117 |
|
} |
118 |
switch ( msg ) { |
|
119 |
case WM_INITDIALOG: |
|
120 |
#ifndef LANG_DE |
/* Dialog box procedure for the WinPT preferences. */ |
121 |
SetWindowText( dlg, _("WinPT Preferences") ); |
BOOL CALLBACK |
122 |
SetDlgItemText( dlg, IDC_PREFS_SECMODE, _("Do not use any &temporary files") ); |
prefs_dlg_proc (HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam) |
123 |
SetDlgItemText( dlg, IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext") ); |
{ |
124 |
SetDlgItemText( dlg, IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column") ); |
int rc; |
125 |
SetDlgItemText( dlg, IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)") ); |
int i, id; |
126 |
#endif |
char t[2]; |
127 |
SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE ); |
char path[256], * p; |
128 |
SetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE ); |
HWND cb; |
129 |
if (reg_prefs.backup.path) |
|
130 |
SetDlgItemText (dlg, IDC_PREFS_BAKPATH, reg_prefs.backup.path); |
switch (msg) { |
131 |
if (reg_prefs.kserv_conf) |
case WM_INITDIALOG: |
132 |
SetDlgItemText (dlg, IDC_PREFS_KSERVER, reg_prefs.kserv_conf); |
SetWindowText (dlg, _("WinPT Preferences")); |
133 |
|
SetDlgItemText (dlg, IDC_PREFS_SECMODE, _("Do not use any &temporary files")); |
134 |
for( i=0; (id=hotkeys[i]); i++ ) |
SetDlgItemText (dlg, IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext")); |
135 |
SetDlgItemText( dlg, id, reg_hotkeys[i].key ); |
SetDlgItemText (dlg, IDC_PREFS_WWINFO, _("Word wrap cleartext &signatures at column")); |
136 |
CheckDlgButton( dlg, IDC_PREFS_DISABLE_HOTKEYS, |
SetDlgItemText (dlg, IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)")); |
137 |
reg_prefs.no_hotkeys ? BST_CHECKED : BST_UNCHECKED ); |
SetDlgItemText (dlg, IDC_PREFS_TRUST, _("Skip key validation and assume that keys are always fully trusted")); |
138 |
CheckDlgButton( dlg, IDC_PREFS_SECMODE, |
SetDlgItemText (dlg, IDC_PREFS_AUTOBACKUP, _("&Automatic keyring backup when WinPT closes")); |
139 |
reg_prefs.use_tmpfiles ? BST_UNCHECKED : BST_CHECKED ); |
SetDlgItemText (dlg, IDC_PREFS_BAKHOME, _("Backup to GPG &home folder")); |
140 |
CheckDlgButton( dlg, IDC_PREFS_VIEWER, |
SetDlgItemText (dlg, IDC_PREFS_BAKUSER, _("Backup to:")); |
141 |
reg_prefs.use_viewer ? BST_CHECKED: BST_UNCHECKED ); |
SetDlgItemText (dlg, IDC_PREFS_KEYLISTINF, _("Select &key list mode")); |
142 |
CheckDlgButton( dlg, IDC_PREFS_TRUST, |
SetDlgItemText (dlg, IDC_PREFS_WIPEINF, _("Select &wipe mode")); |
143 |
reg_prefs.always_trust? BST_CHECKED : BST_UNCHECKED ); |
SetDlgItemText (dlg, IDC_PREFS_KSINF, _("Keyserver &config")); |
144 |
CheckDlgButton( dlg, IDC_PREFS_AUTOBACKUP, |
SetDlgItemText (dlg, IDC_PREFS_CACHEINF, _("Cache &passphrases for 'n' seconds")); |
145 |
reg_prefs.auto_backup? BST_CHECKED : BST_UNCHECKED ); |
SetDlgItemText (dlg, IDC_PREFS_CACHEHINT, _("(CTRL+ALT+F to clear the cache)")); |
146 |
CheckDlgButton( dlg, IDC_PREFS_BAKHOME, |
SetDlgItemText (dlg, IDC_PREFS_ALLOPTINF, _("General options")); |
147 |
reg_prefs.backup.mode==1? BST_CHECKED : BST_UNCHECKED ); |
SetDlgItemText (dlg, IDC_PREFS_CLIPINF, _("Clipboard hotkeys")); |
148 |
CheckDlgButton( dlg, IDC_PREFS_BAKUSER, |
SetDlgItemText (dlg, IDC_PREFS_CURRINF, _("Current window hotkeys")); |
149 |
reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED ); |
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
150 |
if( reg_prefs.no_hotkeys ) |
|
151 |
disable_hotkey_items( dlg, 1 ); |
SetDlgItemInt (dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE); |
152 |
if( !reg_prefs.auto_backup ) |
SetDlgItemInt (dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE); |
153 |
enable_backup_items( dlg, 0 ); |
if (reg_prefs.backup.path) |
154 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKPATH ), |
SetDlgItemText (dlg, IDC_PREFS_BAKPATH, reg_prefs.backup.path); |
155 |
reg_prefs.backup.mode==1?FALSE : TRUE ); |
if (reg_prefs.kserv_conf) |
156 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKSELECT ), |
SetDlgItemText (dlg, IDC_PREFS_KSERVER, reg_prefs.kserv_conf); |
157 |
reg_prefs.backup.mode==1? FALSE : TRUE ); |
|
158 |
set_keylist_mode( dlg ); |
for (i=0; (id=hotkeys[i]); i++) |
159 |
set_wipe_mode( dlg ); |
SetDlgItemText (dlg, id, reg_hotkeys[i].key); |
160 |
center_window( dlg ); |
CheckDlgButton( dlg, IDC_PREFS_DISABLE_HOTKEYS, |
161 |
SetForegroundWindow( dlg ); |
reg_prefs.no_hotkeys ? BST_CHECKED : BST_UNCHECKED ); |
162 |
return TRUE; |
CheckDlgButton( dlg, IDC_PREFS_SECMODE, |
163 |
|
reg_prefs.use_tmpfiles ? BST_UNCHECKED : BST_CHECKED ); |
164 |
case WM_SYSCOMMAND: |
CheckDlgButton( dlg, IDC_PREFS_VIEWER, |
165 |
if( LOWORD( wparam ) == SC_CLOSE ) |
reg_prefs.use_viewer ? BST_CHECKED: BST_UNCHECKED ); |
166 |
EndDialog( dlg, TRUE ); |
CheckDlgButton( dlg, IDC_PREFS_TRUST, |
167 |
return FALSE; |
reg_prefs.always_trust? BST_CHECKED : BST_UNCHECKED ); |
168 |
|
CheckDlgButton( dlg, IDC_PREFS_AUTOBACKUP, |
169 |
case WM_COMMAND: |
reg_prefs.auto_backup? BST_CHECKED : BST_UNCHECKED ); |
170 |
switch( HIWORD(wparam) ) { |
CheckDlgButton( dlg, IDC_PREFS_BAKHOME, |
171 |
case BN_CLICKED: |
reg_prefs.backup.mode==1? BST_CHECKED : BST_UNCHECKED ); |
172 |
switch( (int)LOWORD( wparam ) ) { |
CheckDlgButton( dlg, IDC_PREFS_BAKUSER, |
173 |
case IDC_PREFS_DISABLE_HOTKEYS: |
reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED ); |
174 |
reg_prefs.no_hotkeys ^= 1; |
if (reg_prefs.no_hotkeys) |
175 |
disable_hotkey_items( dlg, reg_prefs.no_hotkeys ); |
disable_hotkey_items (dlg, 1); |
176 |
break; |
if (!reg_prefs.auto_backup) |
177 |
|
enable_backup_items (dlg, 0); |
178 |
case IDC_PREFS_TRUST: |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), |
179 |
reg_prefs.always_trust ^= 1; |
reg_prefs.backup.mode==1?FALSE : TRUE); |
180 |
if( reg_prefs.always_trust ) { |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), |
181 |
msg_box( NULL, |
reg_prefs.backup.mode==1? FALSE : TRUE); |
182 |
_("In most cases it is not a good idea to enable this setting.\n" |
init_keylist_modes (dlg); |
183 |
"If you know what you are doing let this flag enabled, otherwise\n" |
init_wipe_modes (dlg); |
184 |
"it is safe to leave this flag untouched."), |
center_window (dlg, NULL); |
185 |
_("Preferences"), MB_ICONWARNING|MB_OK ); |
SetForegroundWindow (dlg); |
186 |
} |
return TRUE; |
187 |
break; |
|
188 |
|
case WM_SYSCOMMAND: |
189 |
case IDC_PREFS_AUTOBACKUP: |
if (LOWORD (wparam) == SC_CLOSE) |
190 |
reg_prefs.auto_backup ^= 1; |
EndDialog (dlg, TRUE); |
191 |
enable_backup_items( dlg, reg_prefs.auto_backup ); |
return FALSE; |
192 |
break; |
|
193 |
|
case WM_COMMAND: |
194 |
case IDC_PREFS_BAKHOME: |
switch( HIWORD(wparam) ) { |
195 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKSELECT ), FALSE ); |
case BN_CLICKED: |
196 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKPATH ), FALSE ); |
switch( (int)LOWORD( wparam ) ) { |
197 |
break; |
case IDC_PREFS_DISABLE_HOTKEYS: |
198 |
|
reg_prefs.no_hotkeys ^= 1; |
199 |
case IDC_PREFS_BAKUSER: |
disable_hotkey_items (dlg, reg_prefs.no_hotkeys); |
200 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKSELECT ), TRUE ); |
break; |
201 |
EnableWindow( GetDlgItem( dlg, IDC_PREFS_BAKPATH ), TRUE ); |
|
202 |
break; |
case IDC_PREFS_TRUST: |
203 |
} |
reg_prefs.always_trust ^= 1; |
204 |
break; |
if (reg_prefs.always_trust) { |
205 |
} |
msg_box (dlg, |
206 |
switch( LOWORD( wparam ) ) { |
_("In most cases it is not a good idea to enable this setting.\n" |
207 |
case IDC_PREFS_BAKSELECT: |
"If you know what you are doing let this flag enabled, otherwise\n" |
208 |
BROWSEINFO bi; |
"it is safe to leave this flag untouched."), |
209 |
ITEMIDLIST * item; |
_("Preferences"), MB_ICONWARNING|MB_OK); |
210 |
|
} |
211 |
memset( &bi, 0, sizeof (bi) ); |
break; |
212 |
item = SHBrowseForFolder( &bi ); |
|
213 |
if( item ) { |
case IDC_PREFS_AUTOBACKUP: |
214 |
SHGetPathFromIDList( item, path ); |
reg_prefs.auto_backup ^= 1; |
215 |
SetDlgItemText( dlg, IDC_PREFS_BAKPATH, path ); |
enable_backup_items (dlg, reg_prefs.auto_backup); |
216 |
} |
if (reg_prefs.auto_backup == 1) { |
217 |
break; |
if (!IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME) && |
218 |
|
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER)) |
219 |
case IDC_PREFS_KSELFILE: { |
CheckDlgButton (dlg, IDC_PREFS_BAKHOME, BST_CHECKED); |
220 |
const char * name; |
} |
221 |
name = get_filename_dlg (dlg, 0, _("Please select a keyserver.conf file"), |
break; |
222 |
NULL, NULL); |
|
223 |
if (name && file_exist_check (name) == 0) |
case IDC_PREFS_BAKHOME: |
224 |
SetDlgItemText (dlg, IDC_PREFS_KSERVER, name); |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), FALSE); |
225 |
break; } |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), FALSE); |
226 |
|
break; |
227 |
case IDOK: |
|
228 |
rc = GetDlgItemInt( dlg, IDC_PREFS_CACHETIME, NULL, FALSE ); |
case IDC_PREFS_BAKUSER: |
229 |
if( !rc ) |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKSELECT), TRUE); |
230 |
reg_prefs.cache_time = 0; |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), TRUE); |
231 |
else if( rc > 3600 ) { |
break; |
232 |
msg_box( dlg, _("Please enter a value that is between 1-3600.\nIt is not " |
} |
233 |
"a good idea to cache the passphrase more than one hour."), |
break; |
234 |
_("Preferences"), MB_ERR ); |
} |
235 |
SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, 0, FALSE ); |
switch( LOWORD( wparam ) ) { |
236 |
return FALSE; |
case IDC_PREFS_BAKSELECT: |
237 |
} |
const char *bpath; |
238 |
if (reg_prefs.cache_time != rc) |
bpath = get_folder_dlg (dlg, _("Select GPG backup path"), NULL); |
239 |
agent_flush_cache (); |
if (bpath) |
240 |
reg_prefs.cache_time = rc; |
SetDlgItemText (dlg, IDC_PREFS_BAKPATH, bpath); |
241 |
rc = GetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, NULL, FALSE ); |
break; |
242 |
if( !rc ) |
|
243 |
reg_prefs.word_wrap = 0; |
case IDC_PREFS_KSELFILE: { |
244 |
else if( rc > 80 ) { |
const char * name; |
245 |
msg_box( dlg, _("Please enter a value between 1-80."), _("Preferences"), MB_ERR ); |
name = get_fileopen_dlg (dlg, _("Please select a keyserver.conf file"), |
246 |
return FALSE; |
NULL, NULL); |
247 |
} |
if (name != NULL) |
248 |
reg_prefs.word_wrap = rc; |
SetDlgItemText (dlg, IDC_PREFS_KSERVER, name); |
249 |
reg_prefs.use_tmpfiles = IsDlgButtonChecked( dlg, IDC_PREFS_SECMODE )? 0 : 1; |
break; } |
250 |
reg_prefs.use_viewer = IsDlgButtonChecked( dlg, IDC_PREFS_VIEWER )? 1 : 0; |
|
251 |
reg_prefs.backup.mode = IsDlgButtonChecked( dlg, IDC_PREFS_BAKHOME ) ? 1 : |
case IDOK: |
252 |
IsDlgButtonChecked( dlg, IDC_PREFS_BAKUSER )? 2 : 0; |
rc = GetDlgItemInt( dlg, IDC_PREFS_CACHETIME, NULL, FALSE ); |
253 |
if( reg_prefs.backup.mode == 2 ) { |
if (!rc) |
254 |
if( !GetDlgItemText( dlg, IDC_PREFS_BAKPATH, path, sizeof (path)-1 ) |
reg_prefs.cache_time = 0; |
255 |
|| dir_exist_check( path ) ) { |
else if (rc > 3600) { |
256 |
msg_box( dlg, _("The specified backup folder is invalid."), |
msg_box( dlg, _("Please enter a value that is between 1-3600.\nIt is not " |
257 |
_("Preferences"), MB_ERR ); |
"a good idea to cache the passphrase more than one hour."), |
258 |
return FALSE; |
_("Preferences"), MB_ERR); |
259 |
} |
SetDlgItemInt (dlg, IDC_PREFS_CACHETIME, 0, FALSE); |
260 |
free_if_alloc (reg_prefs.backup.path); |
return TRUE; |
261 |
p = reg_prefs.backup.path = m_strdup (path); |
} |
262 |
if (!p) |
if (reg_prefs.cache_time != rc) |
263 |
BUG (0); |
agent_flush_cache (); |
264 |
} |
reg_prefs.cache_time = rc; |
265 |
free_if_alloc (reg_prefs.kserv_conf); |
rc = GetDlgItemInt (dlg, IDC_PREFS_WORDWRAP, NULL, FALSE); |
266 |
if (!GetDlgItemText (dlg, IDC_PREFS_KSERVER, path, sizeof (path)-1) |
if (!rc) |
267 |
|| file_exist_check (path)) { |
reg_prefs.word_wrap = 0; |
268 |
rc = msg_box (dlg, _("The specified keyserver config file is invalid.\n\n" |
else if (rc > 80) { |
269 |
"Create new default config file?"), |
msg_box (dlg, _("Please enter a value between 1-80."), _("Preferences"), MB_ERR); |
270 |
_("Preferences"), MB_ERR|MB_YESNO); |
return TRUE; |
271 |
if (rc == IDNO) |
} |
272 |
return FALSE; |
reg_prefs.word_wrap = rc; |
273 |
else |
reg_prefs.use_tmpfiles = IsDlgButtonChecked( dlg, IDC_PREFS_SECMODE )? 0 : 1; |
274 |
{ |
reg_prefs.use_viewer = IsDlgButtonChecked( dlg, IDC_PREFS_VIEWER )? 1 : 0; |
275 |
char cwd[256], * fn; |
reg_prefs.backup.mode = IsDlgButtonChecked( dlg, IDC_PREFS_BAKHOME ) ? 1 : |
276 |
FILE * fp = fopen ("keyserver.conf", "wb"); |
IsDlgButtonChecked( dlg, IDC_PREFS_BAKUSER )? 2 : 0; |
277 |
if (fp) |
if( reg_prefs.backup.mode == 2 ) { |
278 |
{ |
if( !GetDlgItemText( dlg, IDC_PREFS_BAKPATH, path, sizeof (path)-1 ) |
279 |
fprintf (fp, "%s\r\n", DEF_HKP_KEYSERVER); |
|| dir_exist_check( path ) ) { |
280 |
fclose (fp); |
msg_box( dlg, _("The specified backup folder is invalid."), |
281 |
} |
_("Preferences"), MB_ERR ); |
282 |
GetCurrentDirectory (DIM (cwd)-1, cwd); |
return TRUE; |
283 |
fn = make_filename (cwd, "keyserver", "conf"); |
} |
284 |
memset (path, 0, sizeof( path)); |
free_if_alloc (reg_prefs.backup.path); |
285 |
strncpy (path, fn, DIM (path)-1); |
p = reg_prefs.backup.path = m_strdup (path); |
286 |
free_if_alloc (fn); |
if (!p) |
287 |
} |
BUG (0); |
288 |
} |
} |
289 |
p = reg_prefs.kserv_conf = m_strdup (path); |
free_if_alloc (reg_prefs.kserv_conf); |
290 |
if (!p) |
if (!GetDlgItemText (dlg, IDC_PREFS_KSERVER, path, sizeof (path)-1) |
291 |
BUG (0); |
|| file_exist_check (path)) { |
292 |
|
rc = msg_box (dlg, _("The specified keyserver config file is invalid.\n\n" |
293 |
cb = GetDlgItem( dlg, IDC_PREFS_LISTMODE ); |
"Create new default config file?"), |
294 |
reg_prefs.keylist_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 ); |
_("Preferences"), MB_ERR|MB_YESNO); |
295 |
|
if (rc == IDNO) |
296 |
cb = GetDlgItem( dlg, IDC_PREFS_WIPEMODE ); |
return TRUE; |
297 |
reg_prefs.wipe_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 ); |
else |
298 |
|
{ |
299 |
if (IsDlgButtonChecked (dlg, IDC_PREFS_DISABLE_HOTKEYS)) { |
char cwd[256], * fn; |
300 |
hotkeys_unregister (glob_hwnd); |
FILE * fp = fopen ("keyserver.conf", "wb"); |
301 |
reg_prefs.no_hotkeys = 1; |
if (fp) { |
302 |
} |
fprintf (fp, "%s\r\n", DEF_HKP_KEYSERVER); |
303 |
else { |
fclose (fp); |
304 |
reg_prefs.no_hotkeys = 0; |
} |
305 |
for( i = 0; (id = hotkeys[i]); i++ ) { |
GetCurrentDirectory (DIM (cwd)-1, cwd); |
306 |
rc = GetDlgItemText( dlg, id, t, 2 ); |
fn = make_filename (cwd, "keyserver", "conf"); |
307 |
if( rc && check_hotkey( &t[0] ) ) |
memset (path, 0, sizeof( path)); |
308 |
hotkey_enable( ®_hotkeys[i], t ); |
strncpy (path, fn, DIM (path)-1); |
309 |
else |
free_if_alloc (fn); |
310 |
hotkey_disable( ®_hotkeys[i] ); |
} |
311 |
} |
} |
312 |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "DisableHotkeys", "0"); |
p = reg_prefs.kserv_conf = m_strdup (path); |
313 |
reg_prefs.no_hotkeys = 0; |
if (!p) |
314 |
} |
BUG (0); |
315 |
|
|
316 |
if ((rc = set_reg_winpt_prefs (®_prefs))) |
cb = GetDlgItem( dlg, IDC_PREFS_LISTMODE ); |
317 |
msg_box (dlg, winpt_strerror (rc), _("Preferences"), MB_ERR); |
reg_prefs.keylist_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 ); |
318 |
|
|
319 |
if (reg_prefs.no_hotkeys == 0) { |
cb = GetDlgItem( dlg, IDC_PREFS_WIPEMODE ); |
320 |
hotkeys_unregister (glob_hwnd); |
reg_prefs.wipe_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 ); |
321 |
hotkeys_modify (); |
|
322 |
if ((rc = hotkeys_register (glob_hwnd))) |
if (IsDlgButtonChecked (dlg, IDC_PREFS_DISABLE_HOTKEYS)) { |
323 |
msg_box (NULL, winpt_strerror (rc), _("Hotkeys"), MB_ERR); |
hotkeys_unregister (glob_hwnd); |
324 |
} |
reg_prefs.no_hotkeys = 1; |
325 |
EndDialog (dlg, TRUE); |
} |
326 |
return TRUE; |
else { |
327 |
|
reg_prefs.no_hotkeys = 0; |
328 |
case IDCANCEL: |
for( i = 0; (id = hotkeys[i]); i++ ) { |
329 |
EndDialog( dlg, FALSE ); |
rc = GetDlgItemText( dlg, id, t, 2 ); |
330 |
return FALSE; |
if( rc && check_hotkey( &t[0] ) ) |
331 |
} |
hotkey_enable( ®_hotkeys[i], t ); |
332 |
break; |
else |
333 |
} |
hotkey_disable( ®_hotkeys[i] ); |
334 |
|
} |
335 |
return FALSE; |
set_reg_entry (HKEY_CURRENT_USER, "Software\\WinPT", "DisableHotkeys", "0"); |
336 |
} /* prefs_dlg_proc */ |
reg_prefs.no_hotkeys = 0; |
337 |
|
} |
338 |
|
|
339 |
|
if ((rc = set_reg_winpt_prefs (®_prefs))) |
340 |
|
msg_box (dlg, winpt_strerror (rc), _("Preferences"), MB_ERR); |
341 |
|
|
342 |
|
if (reg_prefs.no_hotkeys == 0) { |
343 |
|
hotkeys_unregister (glob_hwnd); |
344 |
|
hotkeys_modify (); |
345 |
|
if ((rc = hotkeys_register (glob_hwnd))) |
346 |
|
msg_box (NULL, winpt_strerror (rc), _("Hotkeys"), MB_ERR); |
347 |
|
} |
348 |
|
EndDialog (dlg, TRUE); |
349 |
|
return TRUE; |
350 |
|
|
351 |
|
case IDCANCEL: |
352 |
|
/* Reset backup mode if no mode was chosen. */ |
353 |
|
if (reg_prefs.auto_backup == 1 && |
354 |
|
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME) && |
355 |
|
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER)) |
356 |
|
reg_prefs.auto_backup = 0; |
357 |
|
EndDialog (dlg, FALSE); |
358 |
|
return FALSE; |
359 |
|
} |
360 |
|
break; |
361 |
|
} |
362 |
|
|
363 |
|
return FALSE; |
364 |
|
} |