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. */ |
127 |
char path[256], * p; |
char path[256], * p; |
128 |
HWND cb; |
HWND cb; |
129 |
|
|
130 |
switch ( msg ) { |
switch (msg) { |
131 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
|
#ifndef LANG_DE |
|
132 |
SetWindowText (dlg, _("WinPT Preferences")); |
SetWindowText (dlg, _("WinPT Preferences")); |
133 |
SetDlgItemText (dlg, IDC_PREFS_SECMODE, _("Do not use any &temporary files")); |
SetDlgItemText (dlg, IDC_PREFS_SECMODE, _("Do not use any &temporary files")); |
134 |
SetDlgItemText (dlg, IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext")); |
SetDlgItemText (dlg, IDC_PREFS_VIEWER, _("Use clipboard &viewer to display the plaintext")); |
136 |
SetDlgItemText (dlg, IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)")); |
SetDlgItemText (dlg, IDC_PREFS_DISABLE_HOTKEYS, _("&Disable hotkeys (Not recommended!)")); |
137 |
SetDlgItemText (dlg, IDC_PREFS_TRUST, _("Skip key validation and assume that keys are always fully trusted")); |
SetDlgItemText (dlg, IDC_PREFS_TRUST, _("Skip key validation and assume that keys are always fully trusted")); |
138 |
SetDlgItemText (dlg, IDC_PREFS_AUTOBACKUP, _("&Automatic keyring backup when WinPT closes")); |
SetDlgItemText (dlg, IDC_PREFS_AUTOBACKUP, _("&Automatic keyring backup when WinPT closes")); |
139 |
SetDlgItemText (dlg, IDC_PREFS_BAKHOME, _("Backup to GPG &home folder")); |
SetDlgItemText (dlg, IDC_PREFS_BAKHOME, _("Backup to &keyring folder")); |
140 |
SetDlgItemText (dlg, IDC_PREFS_BAKUSER, _("Backup to:")); |
SetDlgItemText (dlg, IDC_PREFS_BAKUSER, _("Backup to:")); |
141 |
#endif |
SetDlgItemText (dlg, IDC_PREFS_KEYLISTINF, _("Select &key list mode")); |
142 |
SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE ); |
SetDlgItemText (dlg, IDC_PREFS_WIPEINF, _("Select &wipe mode")); |
143 |
SetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE ); |
SetDlgItemText (dlg, IDC_PREFS_KSINF, _("Keyserver &config")); |
144 |
|
SetDlgItemText (dlg, IDC_PREFS_CACHEINF, _("Cache &passphrases for 'n' seconds")); |
145 |
|
SetDlgItemText (dlg, IDC_PREFS_CACHEHINT, _("(CTRL+ALT+F to clear the cache)")); |
146 |
|
SetDlgItemText (dlg, IDC_PREFS_ALLOPTINF, _("General options")); |
147 |
|
SetDlgItemText (dlg, IDC_PREFS_CLIPINF, _("Clipboard hotkeys")); |
148 |
|
SetDlgItemText (dlg, IDC_PREFS_CURRINF, _("Current window hotkeys")); |
149 |
|
SetDlgItemText (dlg, IDC_PREFS_KSELFILE, _("Browse...")); |
150 |
|
SetDlgItemText (dlg, IDC_PREFS_BAKSELECT, _("Browse...")); |
151 |
|
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
152 |
|
|
153 |
|
SetDlgItemInt (dlg, IDC_PREFS_CACHETIME, reg_prefs.cache_time, TRUE); |
154 |
|
SetDlgItemInt (dlg, IDC_PREFS_WORDWRAP, reg_prefs.word_wrap, TRUE); |
155 |
if (reg_prefs.backup.path) |
if (reg_prefs.backup.path) |
156 |
SetDlgItemText (dlg, IDC_PREFS_BAKPATH, 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); |
|
157 |
|
|
158 |
for (i=0; (id=hotkeys[i]); i++) |
for (i=0; (id=hotkeys[i]); i++) |
159 |
SetDlgItemText (dlg, id, reg_hotkeys[i].key); |
SetDlgItemText (dlg, id, reg_hotkeys[i].key); |
171 |
reg_prefs.backup.mode==1? BST_CHECKED : BST_UNCHECKED ); |
reg_prefs.backup.mode==1? BST_CHECKED : BST_UNCHECKED ); |
172 |
CheckDlgButton( dlg, IDC_PREFS_BAKUSER, |
CheckDlgButton( dlg, IDC_PREFS_BAKUSER, |
173 |
reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED ); |
reg_prefs.backup.mode==2? BST_CHECKED : BST_UNCHECKED ); |
174 |
if( reg_prefs.no_hotkeys ) |
if (reg_prefs.no_hotkeys) |
175 |
disable_hotkey_items( dlg, 1 ); |
disable_hotkey_items (dlg, 1); |
176 |
if (!reg_prefs.auto_backup) |
if (!reg_prefs.auto_backup) |
177 |
enable_backup_items (dlg, 0); |
enable_backup_items (dlg, 0); |
178 |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), |
EnableWindow (GetDlgItem (dlg, IDC_PREFS_BAKPATH), |
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 let this flag enabled, 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: |
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) |
248 |
reg_prefs.cache_time = 0; |
reg_prefs.cache_time = 0; |
249 |
else if( rc > 3600 ) { |
else if (rc > 3600) { |
250 |
msg_box( dlg, _("Please enter a value that is between 1-3600.\nIt is not " |
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."), |
"a good idea to cache the passphrase more than one hour."), |
252 |
_("Preferences"), MB_ERR ); |
_("Preferences"), MB_ERR); |
253 |
SetDlgItemInt( dlg, IDC_PREFS_CACHETIME, 0, FALSE ); |
SetDlgItemInt (dlg, IDC_PREFS_CACHETIME, 0, FALSE); |
254 |
return TRUE; |
return TRUE; |
255 |
} |
} |
256 |
if (reg_prefs.cache_time != rc) |
if (reg_prefs.cache_time != rc) |
257 |
agent_flush_cache (); |
agent_flush_cache (); |
258 |
reg_prefs.cache_time = rc; |
reg_prefs.cache_time = rc; |
259 |
rc = GetDlgItemInt( dlg, IDC_PREFS_WORDWRAP, NULL, FALSE ); |
rc = GetDlgItemInt (dlg, IDC_PREFS_WORDWRAP, NULL, FALSE); |
260 |
if( !rc ) |
if (!rc) |
261 |
reg_prefs.word_wrap = 0; |
reg_prefs.word_wrap = 0; |
262 |
else if( rc > 80 ) { |
else if (rc > 80) { |
263 |
msg_box( dlg, _("Please enter a value between 1-80."), _("Preferences"), MB_ERR ); |
msg_box (dlg, _("Please enter a value between 1-80."), _("Preferences"), MB_ERR); |
264 |
return TRUE; |
return TRUE; |
265 |
} |
} |
266 |
reg_prefs.word_wrap = rc; |
reg_prefs.word_wrap = rc; |
280 |
if (!p) |
if (!p) |
281 |
BUG (0); |
BUG (0); |
282 |
} |
} |
|
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); |
|
283 |
|
|
284 |
cb = GetDlgItem( dlg, IDC_PREFS_LISTMODE ); |
cb = GetDlgItem( dlg, IDC_PREFS_LISTMODE ); |
285 |
reg_prefs.keylist_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 ); |
reg_prefs.keylist_mode = SendMessage( cb, CB_GETCURSEL, 0, 0 ); |
317 |
return TRUE; |
return TRUE; |
318 |
|
|
319 |
case IDCANCEL: |
case IDCANCEL: |
320 |
EndDialog( dlg, FALSE ); |
/* Reset backup mode if no mode was chosen. */ |
321 |
|
if (reg_prefs.auto_backup == 1 && |
322 |
|
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKHOME) && |
323 |
|
!IsDlgButtonChecked (dlg, IDC_PREFS_BAKUSER)) |
324 |
|
reg_prefs.auto_backup = 0; |
325 |
|
EndDialog (dlg, FALSE); |
326 |
return FALSE; |
return FALSE; |
327 |
} |
} |
328 |
break; |
break; |