34 |
#include "wptW32API.h" |
#include "wptW32API.h" |
35 |
|
|
36 |
|
|
37 |
|
/* Enable all edit items if @val is TRUE, disable them otherwise. */ |
38 |
|
static void |
39 |
|
enable_disable_items (HWND dlg, BOOL val) |
40 |
|
{ |
41 |
|
EnableWindow (GetDlgItem (dlg, IDC_GPGPREFS_EXEDIR), val); |
42 |
|
EnableWindow (GetDlgItem (dlg, IDC_GPGREFS_EXEDLG), val); |
43 |
|
EnableWindow (GetDlgItem (dlg, IDC_GPGPREFS_LOCALE), val); |
44 |
|
EnableWindow (GetDlgItem (dlg, IDC_GPGPREFS_LOCDLG), val); |
45 |
|
EnableWindow (GetDlgItem (dlg, IDC_GPGPREFS_HOMEDIR), val); |
46 |
|
EnableWindow (GetDlgItem (dlg, IDC_GPGPREFS_HOMEDLG), val); |
47 |
|
} |
48 |
|
|
49 |
|
|
50 |
/* Load the GPG4WIN default values and disabled the |
/* Load the GPG4WIN default values and disabled the |
51 |
dialog items to indicate these are fixed values. |
dialog items to indicate these are fixed values. |
52 |
Return value: true if GPG4win was found. */ |
Return value: true if GPG4win was found. */ |
146 |
SetDlgItemText ( dlg, IDC_GPGPREFS_LOCALINF, |
SetDlgItemText ( dlg, IDC_GPGPREFS_LOCALINF, |
147 |
_("Locale directory (to access the translation files)")); |
_("Locale directory (to access the translation files)")); |
148 |
SetDlgItemText (dlg, IDC_GPGPREFS_ASKLEVEL, _("Ask for the signature class during key sign")); |
SetDlgItemText (dlg, IDC_GPGPREFS_ASKLEVEL, _("Ask for the signature class during key sign")); |
149 |
|
SetDlgItemText (dlg, IDC_GPGPREFS_ASKEXPIRE, _("Allow to set an expiration date for signatures")); |
150 |
SetDlgItemText (dlg, IDC_GPGPREFS_CMTINF, _("Comment in armored files")); |
SetDlgItemText (dlg, IDC_GPGPREFS_CMTINF, _("Comment in armored files")); |
151 |
SetDlgItemText (dlg, IDC_GPGPREFS_ENCINF, _("Encrypt to this key")); |
SetDlgItemText (dlg, IDC_GPGPREFS_ENCINF, _("Encrypt to this key")); |
152 |
SetDlgItemText (dlg, IDC_GPGPREFS_ALLOPTINF, _("General GPG options")); |
SetDlgItemText (dlg, IDC_GPGPREFS_ALLOPTINF, _("General GPG options")); |
153 |
|
SetDlgItemText (dlg, IDC_GPGPREFS_HOMEDLG, _("Browse...")); |
154 |
|
SetDlgItemText (dlg, IDC_GPGREFS_EXEDLG, _("Browse...")); |
155 |
|
SetDlgItemText (dlg, IDC_GPGPREFS_LOCDLG, _("Browse...")); |
156 |
|
SetDlgItemText (dlg, IDC_GPGPREFS_OVRDEFAULT, _("&Overwrite default settings")); |
157 |
|
SetDlgItemText (dlg, IDCANCEL, _("&Cancel")); |
158 |
|
|
159 |
gpg4win = load_gpg4win_values (dlg); |
gpg4win = load_gpg4win_values (dlg); |
160 |
if (!gpg4win) |
if (!gpg4win) { |
161 |
load_registry_values (dlg); |
load_registry_values (dlg); |
162 |
|
CheckDlgButton (dlg, IDC_GPGPREFS_OVRDEFAULT, BST_CHECKED); |
163 |
|
} |
164 |
|
|
165 |
p = get_gnupg_cfgfile (); |
p = get_gnupg_cfgfile (); |
166 |
if (p) { |
if (p) { |
167 |
parse_gpg_options (p, &opt); |
parse_gpg_options (p, &opt); |
168 |
free_if_alloc (p); |
free_if_alloc (p); |
169 |
if (opt) { |
if (opt) { |
170 |
|
if (find_option (opt, "ask-cert-expire")) |
171 |
|
CheckDlgButton (dlg, IDC_GPGPREFS_ASKEXPIRE, BST_CHECKED); |
172 |
if (find_option (opt, "ask-cert-level")) |
if (find_option (opt, "ask-cert-level")) |
173 |
CheckDlgButton (dlg, IDC_GPGPREFS_ASKLEVEL, BST_CHECKED); |
CheckDlgButton (dlg, IDC_GPGPREFS_ASKLEVEL, BST_CHECKED); |
174 |
if ((e=find_option (opt, "comment"))) |
e = find_option (opt, "comment"); |
175 |
SetDlgItemText (dlg, IDC_GPGPREFS_COMMENT, e->val); |
if (e != NULL) |
176 |
if ((e=find_option (opt, "encrypt-to"))) |
SetDlgItemText (dlg, IDC_GPGPREFS_COMMENT, e->val); |
177 |
|
e = find_option (opt, "encrypt-to"); |
178 |
|
if (e != NULL) |
179 |
SetDlgItemText (dlg, IDC_GPGPREFS_ENCTO, e->val); |
SetDlgItemText (dlg, IDC_GPGPREFS_ENCTO, e->val); |
180 |
release_gpg_options (opt); |
release_gpg_options (opt); |
181 |
} |
} |
191 |
|
|
192 |
case WM_SYSCOMMAND: |
case WM_SYSCOMMAND: |
193 |
if (LOWORD (wparam) == SC_CLOSE) |
if (LOWORD (wparam) == SC_CLOSE) |
194 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, FALSE); |
195 |
return FALSE; |
return FALSE; |
196 |
|
|
197 |
case WM_COMMAND: |
case WM_COMMAND: |
198 |
|
if (HIWORD (wparam) == BN_CLICKED && |
199 |
|
LOWORD (wparam) == IDC_GPGPREFS_OVRDEFAULT) { |
200 |
|
if (IsDlgButtonChecked (dlg, LOWORD (wparam))) { |
201 |
|
enable_disable_items (dlg, TRUE); |
202 |
|
gpg4win = false; |
203 |
|
} |
204 |
|
else { |
205 |
|
enable_disable_items (dlg, FALSE); |
206 |
|
gpg4win = true; |
207 |
|
} |
208 |
|
break; |
209 |
|
} |
210 |
|
|
211 |
switch (LOWORD (wparam)) { |
switch (LOWORD (wparam)) { |
212 |
case IDC_GPGPREFS_SAVE: |
case IDC_GPGPREFS_SAVE: |
213 |
if (!GetDlgItemText (dlg, IDC_GPGPREFS_HOMEDIR, |
if (!GetDlgItemText (dlg, IDC_GPGPREFS_HOMEDIR, |
214 |
homedir, sizeof (homedir) -1)) { |
homedir, sizeof (homedir) -1)) { |
215 |
msg_box (dlg, _("Please enter the GnuPG home directory."), |
msg_box (dlg, _("Please enter the GnuPG home directory."), |
216 |
_("Preferences"), MB_ERR); |
_("Preferences"), MB_ERR); |
217 |
return FALSE; |
return FALSE; |
218 |
} |
} |
219 |
if (dir_exist_check (homedir)) { |
if (dir_exist_check (homedir)) { |
220 |
_snprintf (t, sizeof (t) - 1, "%s: %s", homedir, |
_snprintf (t, sizeof (t) - 1, "%s: %s", homedir, |
221 |
winpt_strerror (WPTERR_DIR_OPEN)); |
winpt_strerror (WPTERR_DIR_OPEN)); |
222 |
msg_box (dlg, t, _("Preferences"), MB_ERR); |
msg_box (dlg, t, _("Preferences"), MB_ERR); |
223 |
return FALSE; |
return FALSE; |
235 |
return FALSE; |
return FALSE; |
236 |
} |
} |
237 |
if (file_exist_check (exedir)) { |
if (file_exist_check (exedir)) { |
238 |
msg_box (dlg, _("Could not find the GPG program in this directory."), |
msg_box (dlg, _("Could not find the GPG program in this directory."), |
239 |
_("Preferences"), MB_ERR); |
_("Preferences"), MB_ERR); |
240 |
return FALSE; |
return FALSE; |
241 |
} |
} |
242 |
if (!gpg4win && set_reg_entry_gpg ("gpgProgram", exedir)) { |
if (!gpg4win && set_reg_entry_gpg ("gpgProgram", exedir)) { |
243 |
msg_box (dlg, _("Could not save 'gpgProgram' in the registry"), |
msg_box (dlg, _("Could not save 'gpgProgram' in the registry"), |
244 |
_("Preferences"), MB_ERR); |
_("Preferences"), MB_ERR); |
245 |
return FALSE; |
return FALSE; |
246 |
} |
} |
247 |
if (GetDlgItemText (dlg, IDC_GPGPREFS_LOCALE, locale_dir, sizeof (locale_dir) -1)) { |
if (GetDlgItemText (dlg, IDC_GPGPREFS_LOCALE, |
248 |
|
locale_dir, sizeof (locale_dir) -1) > 0) { |
249 |
if (dir_exist_check (locale_dir)) { |
if (dir_exist_check (locale_dir)) { |
250 |
log_box ( _("Preferences"), MB_ERR, "%s: %s", locale_dir, |
log_box ( _("Preferences"), MB_ERR, "%s: %s", locale_dir, |
251 |
winpt_strerror (WPTERR_DIR_OPEN)); |
winpt_strerror (WPTERR_DIR_OPEN)); |
266 |
} |
} |
267 |
parse_gpg_options (p, &opt); |
parse_gpg_options (p, &opt); |
268 |
|
|
269 |
if( IsDlgButtonChecked( dlg, IDC_GPGPREFS_ASKLEVEL ) ) { |
if (IsDlgButtonChecked (dlg, IDC_GPGPREFS_ASKLEVEL)) { |
270 |
modify_entry( opt, ENTRY_SINGLE, "ask-cert-level", NULL ); |
modify_entry (opt, ENTRY_SINGLE, "ask-cert-level", NULL); |
271 |
reg_prefs.gpg.ask_cert_level = 1; |
reg_prefs.gpg.ask_cert_level = 1; |
272 |
} |
} |
273 |
else { |
else { |
274 |
delete_option (opt, "ask-cert-level"); |
delete_option (opt, "ask-cert-level"); |
275 |
reg_prefs.gpg.ask_cert_level = 0; |
reg_prefs.gpg.ask_cert_level = 0; |
276 |
} |
} |
277 |
|
if (IsDlgButtonChecked (dlg, IDC_GPGPREFS_ASKEXPIRE)) { |
278 |
|
modify_entry (opt, ENTRY_SINGLE, "ask-cert-expire", NULL); |
279 |
|
reg_prefs.gpg.ask_cert_expire = 1; |
280 |
|
} |
281 |
|
else { |
282 |
|
delete_option (opt, "ask-cert-expire"); |
283 |
|
reg_prefs.gpg.ask_cert_expire = 0; |
284 |
|
} |
285 |
|
|
286 |
if( (n = GetDlgItemText(dlg, IDC_GPGPREFS_COMMENT, t, sizeof t - 1 ) )) |
n = GetDlgItemText(dlg, IDC_GPGPREFS_COMMENT, t, sizeof t - 1); |
287 |
modify_entry( opt, ENTRY_MULTI, "comment", t ); |
if (n > 0) |
288 |
else if( n == 0 ) |
modify_entry (opt, ENTRY_MULTI, "comment", t); |
289 |
modify_entry( opt, ENTRY_MULTI, "comment", "\"\"" ); |
else if (n == 0) |
290 |
|
modify_entry (opt, ENTRY_MULTI, "comment", "\"\""); |
291 |
else |
else |
292 |
delete_option( opt, "comment" ); |
delete_option (opt, "comment"); |
293 |
|
|
294 |
if( (n=GetDlgItemText( dlg, IDC_GPGPREFS_ENCTO, t, sizeof t -1 ) ) ) |
n = GetDlgItemText (dlg, IDC_GPGPREFS_ENCTO, t, sizeof t -1); |
295 |
modify_entry( opt, ENTRY_MULTI, "encrypt-to", t ); |
if (n > 0) |
296 |
|
modify_entry (opt, ENTRY_MULTI, "encrypt-to", t); |
297 |
else |
else |
298 |
delete_option( opt, "encrypt-to" ); |
delete_option (opt, "encrypt-to"); |
299 |
|
|
300 |
commit_gpg_options (p, opt); |
commit_gpg_options (p, opt); |
301 |
release_gpg_options (opt); |
release_gpg_options (opt); |
308 |
char *name; |
char *name; |
309 |
|
|
310 |
SetDlgItemText (dlg, IDC_GPGPREFS_HOMEDIR, folder); |
SetDlgItemText (dlg, IDC_GPGPREFS_HOMEDIR, folder); |
311 |
if (GetDlgItemText (dlg, IDC_GPGPREFS_EXEDIR, exedir, DIM (exedir)-1) > 0) |
if (GetDlgItemText (dlg, IDC_GPGPREFS_EXEDIR, |
312 |
|
exedir, DIM (exedir)-1) > 0) |
313 |
break; |
break; |
314 |
name = make_filename (folder, "gpg", "exe"); |
name = make_filename (folder, "gpg", "exe"); |
315 |
if (file_exist_check (name) == 0) |
if (file_exist_check (name) == 0) |
323 |
return TRUE; |
return TRUE; |
324 |
|
|
325 |
case IDC_GPGPREFS_LOCDLG: |
case IDC_GPGPREFS_LOCDLG: |
326 |
folder = get_folder_dlg (dlg, _("Choose locale directory"), NULL); |
folder = get_folder_dlg (dlg, _("Choose Locale Directory"), NULL); |
327 |
if (folder) |
if (folder) |
328 |
SetDlgItemText (dlg, IDC_GPGPREFS_LOCALE, folder); |
SetDlgItemText (dlg, IDC_GPGPREFS_LOCALE, folder); |
329 |
return TRUE; |
return TRUE; |
330 |
|
|
331 |
case IDC_GPGREFS_EXEDLG: |
case IDC_GPGREFS_EXEDLG: |
332 |
s = get_fileopen_dlg (dlg, _("Choose GPG binary"), |
s = get_fileopen_dlg (dlg, _("Choose GPG binary"), |
333 |
_("Executable Files (*.exe)\0*.exe\0\0"), |
"Executable Files (*.exe)\0*.exe\0\0", |
334 |
NULL); |
NULL); |
335 |
if (s) |
if (s) |
336 |
SetDlgItemText (dlg, IDC_GPGPREFS_EXEDIR, s); |
SetDlgItemText (dlg, IDC_GPGPREFS_EXEDIR, s); |