41 |
LOCK mo_file; |
LOCK mo_file; |
42 |
int scard_support = 0; |
int scard_support = 0; |
43 |
int debug = 0; |
int debug = 0; |
44 |
|
int mobile = 0; |
45 |
int gpg_read_only = 0; |
int gpg_read_only = 0; |
46 |
char gpgver[3]; |
char gpgver[3]; |
47 |
|
|
128 |
return NULL; |
return NULL; |
129 |
strncpy (currdir, cmd, 255); |
strncpy (currdir, cmd, 255); |
130 |
j = strlen (currdir); |
j = strlen (currdir); |
131 |
while (j--) |
while (j--) { |
|
{ |
|
132 |
if (currdir[j] == '\\') |
if (currdir[j] == '\\') |
133 |
break; |
break; |
134 |
} |
} |
157 |
ma, mi, pa); |
ma, mi, pa); |
158 |
return rc; |
return rc; |
159 |
} |
} |
160 |
/* We enable smartcard support for GPG: 1.9.x and >= 1.3.90 */ |
/* We enable smartcard support for GPG: 1.9.x or >= 1.4.0 */ |
161 |
if (ma > 1 || mi >= 9 || mi > 3) |
if (ma >= 1 && mi >= 4) |
162 |
scard_support = 1; |
scard_support = 1; |
163 |
|
|
164 |
gpgver[0] = ma; |
gpgver[0] = ma; |
187 |
} |
} |
188 |
|
|
189 |
|
|
190 |
|
static void |
191 |
|
enable_mobile_mode (void) |
192 |
|
{ |
193 |
|
memset (®_prefs, 0, sizeof (reg_prefs)); |
194 |
|
reg_prefs.always_trust = 0; |
195 |
|
reg_prefs.auto_backup = 0; |
196 |
|
reg_prefs.cache_time = 0; |
197 |
|
reg_prefs.expert = 0; |
198 |
|
reg_prefs.keylist_mode = 1; |
199 |
|
reg_prefs.kserv_conf = m_strdup ("keyserver.conf"); |
200 |
|
reg_prefs.no_zip_mmedia = 1; |
201 |
|
reg_prefs.use_tmpfiles = 1; |
202 |
|
reg_prefs.word_wrap = 80; |
203 |
|
reg_prefs.use_viewer = 0; /* XXX */ |
204 |
|
} |
205 |
|
|
206 |
|
char* get_subkey_fingerprint (gpgme_ctx_t ctx, const char *keyid); |
207 |
|
|
208 |
int WINAPI |
int WINAPI |
209 |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
210 |
{ |
{ |
225 |
gpgme_set_pgm_string ("WinPT "PGM_VERSION); |
gpgme_set_pgm_string ("WinPT "PGM_VERSION); |
226 |
|
|
227 |
s = PTD_get_version (); |
s = PTD_get_version (); |
228 |
if (strcmp (s, "0.8.0")) |
if (strcmp (s, "0.8.0")) { |
|
{ |
|
229 |
log_box (_("Privacy Tray Dynamic (PTD)"), MB_ERR, |
log_box (_("Privacy Tray Dynamic (PTD)"), MB_ERR, |
230 |
_("Please update your PTD.dll to the newest version, " |
_("Please update your PTD.dll to the newest version, " |
231 |
"the version (%s) you use is too old."), s); |
"the version (%s) you use is too old."), s); |
232 |
return 0; |
return 0; |
233 |
} |
} |
234 |
|
|
235 |
if (gpg_md_selftest ()) |
if (gpg_md_selftest ()) { |
|
{ |
|
236 |
msg_box (NULL, _("Cryptographic selftest failed."), |
msg_box (NULL, _("Cryptographic selftest failed."), |
237 |
_("WinPT Error"), MB_ERR); |
_("WinPT Error"), MB_ERR); |
238 |
return 0; |
return 0; |
239 |
} |
} |
240 |
|
|
241 |
|
if (cmdline && stristr (cmdline, "--mobile")) |
242 |
|
mobile = 1; |
243 |
|
|
244 |
set_default_kserver (); |
set_default_kserver (); |
245 |
regist_inst_gnupg (1); |
|
246 |
regist_inst_winpt (1, &created); |
if (!mobile) { |
247 |
if (!created) |
regist_inst_gnupg (1); |
248 |
{ |
regist_inst_winpt (1, &created); |
249 |
|
} |
250 |
|
else { |
251 |
|
enable_mobile_mode (); |
252 |
|
/* XXX: ask for GPG path */ |
253 |
|
created = 1; /* Disable registry writing */ |
254 |
|
} |
255 |
|
|
256 |
|
if (!created) { |
257 |
memset (®_prefs, 0, sizeof (reg_prefs)); |
memset (®_prefs, 0, sizeof (reg_prefs)); |
258 |
reg_prefs.use_tmpfiles = 1; /* default */ |
reg_prefs.use_tmpfiles = 1; /* default */ |
259 |
|
reg_prefs.fm.progress = 0; /* XXX: fix the bug and enable it again */ |
260 |
get_reg_winpt_prefs (®_prefs); |
get_reg_winpt_prefs (®_prefs); |
261 |
if (!reg_prefs.no_hotkeys) |
if (!reg_prefs.no_hotkeys) |
262 |
hotkeys_modify (); |
hotkeys_modify (); |
263 |
} |
} |
264 |
|
|
265 |
rc = gnupg_check_homedir (); |
rc = gnupg_check_homedir (); |
266 |
if (rc) |
if (rc) { |
|
{ |
|
267 |
log_box (_("WinPT Error"), MB_ERR, |
log_box (_("WinPT Error"), MB_ERR, |
268 |
_("GPG home directory is not set correctly.\n" |
_("GPG home directory is not set correctly.\n" |
269 |
"Please check the GPG registry settings:\n%s."), |
"Please check the GPG registry settings:\n%s."), |
292 |
gnupg_check_homedir (); /* change gpgProgram if needed */ |
gnupg_check_homedir (); /* change gpgProgram if needed */ |
293 |
} |
} |
294 |
} |
} |
295 |
else |
else { |
|
{ |
|
296 |
msg_box (NULL, _("GPG home directory could not be determited."), |
msg_box (NULL, _("GPG home directory could not be determited."), |
297 |
_("WinPT Error"), MB_ERR); |
_("WinPT Error"), MB_ERR); |
298 |
goto start; |
goto start; |
300 |
} |
} |
301 |
|
|
302 |
rc = check_gnupg_prog (); |
rc = check_gnupg_prog (); |
303 |
if (rc) |
if (rc) { |
|
{ |
|
304 |
if (msg_box (NULL, _("Could not find the GPG binary (gpg.exe).\n" |
if (msg_box (NULL, _("Could not find the GPG binary (gpg.exe).\n" |
305 |
"Do you want to start the GPG preferences to " |
"Do you want to start the GPG preferences to " |
306 |
"correct this problem?"), _("WinPT Error"), |
"correct this problem?"), _("WinPT Error"), |
385 |
return 0; |
return 0; |
386 |
} |
} |
387 |
|
|
388 |
/*if (file_exist_check ("loadimage.exe")) |
if (cmdline) { |
389 |
PTD_create_loadimage (NULL);*/ |
if (stristr (cmdline, "--enable-debug") || stristr (cmdline, "--debug")) { |
390 |
|
gpgme_set_debug_mode (1); |
391 |
if (cmdline && stristr (cmdline, "--enable-debug")) { |
winpt_debug_msg (); |
392 |
gpgme_set_debug_mode (1); |
debug = 1; |
393 |
winpt_debug_msg (); |
} |
|
debug = 1; |
|
394 |
} |
} |
395 |
|
|
396 |
wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT)); |
wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT)); |
453 |
hwnd, keygen_wizard_dlg_proc, (LPARAM)&c); |
hwnd, keygen_wizard_dlg_proc, (LPARAM)&c); |
454 |
if (!rc) |
if (!rc) |
455 |
goto start; |
goto start; |
|
update_keycache (hwnd); |
|
|
check_crypto_engine (); |
|
456 |
break; |
break; |
457 |
|
|
458 |
case SETUP_IMPORT: |
case SETUP_IMPORT: |
461 |
msg_box (hwnd, winpt_strerror (rc), _("WinPT Error"), MB_ERR); |
msg_box (hwnd, winpt_strerror (rc), _("WinPT Error"), MB_ERR); |
462 |
goto start; |
goto start; |
463 |
} |
} |
|
update_keycache (hwnd); |
|
|
check_crypto_engine (); |
|
464 |
break; |
break; |
465 |
|
|
466 |
case SETUP_EXISTING: |
case SETUP_EXISTING: |
467 |
break; /* todo */ |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
468 |
|
gpgprefs_dlg_proc, NULL); |
469 |
|
break; |
470 |
|
|
471 |
case -1: |
case -1: |
472 |
DestroyWindow (hwnd); |
DestroyWindow (hwnd); |
473 |
free_gnupg_table (); |
free_gnupg_table (); |
474 |
return 0; |
return 0; |
475 |
} |
} |
476 |
|
update_keycache (hwnd); |
477 |
|
check_crypto_engine (); |
478 |
} |
} |
479 |
else { |
else { |
480 |
gpgme_keycache_t c; |
gpgme_keycache_t c; |