102 |
} |
} |
103 |
|
|
104 |
|
|
105 |
|
/* Return true if the GPG environment is useable. */ |
106 |
|
static bool |
107 |
|
gpg_prefs_ok (void) |
108 |
|
{ |
109 |
|
char *p; |
110 |
|
|
111 |
|
p = get_reg_entry_gpg4win ("gpg.exe"); |
112 |
|
if (!p || file_exist_check (p) != 0) { |
113 |
|
free_if_alloc (p); |
114 |
|
p = get_reg_entry_gpg ("gpgProgram"); |
115 |
|
if (!p || file_exist_check (p) != 0) { |
116 |
|
free_if_alloc (p); |
117 |
|
return false; |
118 |
|
} |
119 |
|
} |
120 |
|
free_if_alloc (p); |
121 |
|
p = get_reg_entry_gpg4win (NULL); |
122 |
|
if (!p || dir_exist_check (p) != 0) { |
123 |
|
free_if_alloc (p); |
124 |
|
p = get_reg_entry_gpg ("HomeDir"); |
125 |
|
if (!p || dir_exist_check (p) != 0) { |
126 |
|
free_if_alloc (p); |
127 |
|
return false; |
128 |
|
} |
129 |
|
} |
130 |
|
free_if_alloc (p); |
131 |
|
return true; |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
|
|
136 |
/* Load the GPG environment. On the first start, some |
/* Load the GPG environment. On the first start, some |
137 |
checks are performed to find out in what state GPG is. |
checks are performed to find out in what state GPG is. |
138 |
Return value: 0 everything OK. |
Return value: 0 everything OK. |
153 |
return (1); |
return (1); |
154 |
} |
} |
155 |
free_if_alloc (p); |
free_if_alloc (p); |
156 |
p = multi_gnupg_path (0); |
|
157 |
|
p = get_reg_entry_gpg ("HomeDir"); |
158 |
|
if (!p || dir_exist_check (p) != 0) { |
159 |
|
free_if_alloc (p); |
160 |
|
p = multi_gnupg_path (0); |
161 |
|
} |
162 |
if (p && dir_exist_check (p)) { |
if (p && dir_exist_check (p)) { |
163 |
memset (&sec_attr, 0, sizeof (sec_attr)); |
memset (&sec_attr, 0, sizeof (sec_attr)); |
164 |
sec_attr.nLength = sizeof (sec_attr); |
sec_attr.nLength = sizeof (sec_attr); |
467 |
winpt_strerror (rc)); |
winpt_strerror (rc)); |
468 |
s = get_fileopen_dlg (GetActiveWindow (), |
s = get_fileopen_dlg (GetActiveWindow (), |
469 |
_("Select GPG Public Keyring"), |
_("Select GPG Public Keyring"), |
470 |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), |
"GPG Keyrings (*.gpg)\0*.gpg\0\0", |
471 |
NULL); |
NULL); |
472 |
if (s != NULL) { |
if (s != NULL) { |
473 |
size_t n; |
size_t n; |
626 |
} |
} |
627 |
|
|
628 |
if (first_start) { |
if (first_start) { |
|
struct first_start_s fs; |
|
629 |
struct genkey_s c; |
struct genkey_s c; |
630 |
|
int choice; |
631 |
HWND h; |
HWND h; |
632 |
start: |
start: |
633 |
h = GetDesktopWindow (); |
h = GetDesktopWindow (); |
634 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, h, |
if (!gpg_prefs_ok ()) |
635 |
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, h, |
636 |
gpgprefs_dlg_proc, 0); |
gpgprefs_dlg_proc, 0); |
637 |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, h, |
choice = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, h, |
638 |
first_run_dlg_proc, (LPARAM)&fs); |
first_run_dlg_proc, 0); |
639 |
switch (fs.choice) { |
switch (choice) { |
640 |
case SETUP_KEYGEN: |
case SETUP_KEYGEN: |
641 |
c.interactive = 1; |
c.interactive = 1; |
642 |
c.first_start = 1; |
c.first_start = 1; |
654 |
} |
} |
655 |
break; |
break; |
656 |
|
|
657 |
case -1: /* Cancel/Abort. */ |
case 0: /* Cancel/Abort. */ |
658 |
|
default: |
659 |
DestroyWindow (hwnd); |
DestroyWindow (hwnd); |
660 |
free_gnupg_table (); |
free_gnupg_table (); |
661 |
return 0; |
return 0; |
662 |
} |
} |
663 |
update_keycache (hwnd); |
update_keycache (hwnd); |
664 |
check_crypto_engine (); |
if (!check_crypto_engine ()) { |
665 |
|
DestroyWindow (hwnd); |
666 |
|
free_gnupg_table (); |
667 |
|
return 0; |
668 |
|
} |
669 |
} |
} |
670 |
else { |
else { |
671 |
gpg_keycache_t c; |
gpg_keycache_t c; |