22 |
#endif |
#endif |
23 |
|
|
24 |
#include <windows.h> |
#include <windows.h> |
|
#include <windows.h> |
|
25 |
|
|
26 |
#include "../resource.h" |
#include "resource.h" |
27 |
#include "wptTypes.h" |
#include "wptTypes.h" |
28 |
#include "wptW32API.h" |
#include "wptW32API.h" |
29 |
#include "wptVersion.h" |
#include "wptVersion.h" |
38 |
#include "wptFileManager.h" |
#include "wptFileManager.h" |
39 |
#include "wptContext.h" |
#include "wptContext.h" |
40 |
#include "wptCardEdit.h" |
#include "wptCardEdit.h" |
41 |
|
#include "wptCrypto.h" |
42 |
|
|
43 |
#define MIN_GPG_VER "1.4.3" /* Minimal GPG version. */ |
#define MIN_GPG_VER "1.4.3" /* Minimal GPG version. */ |
44 |
#define MIN_GPGME_VER "1.2.0" /* Minimal GPGME version. */ |
#define MIN_GPGME_VER "1.2.0" /* Minimal GPGME version. */ |
|
#define MIN_PTD_VER "0.8.1" /* Minimal PTD version. */ |
|
45 |
|
|
46 |
|
|
47 |
HINSTANCE glob_hinst; /* global instance for the dialogs */ |
HINSTANCE glob_hinst; /* global instance for the dialogs */ |
126 |
defkey = get_gnupg_default_key (); |
defkey = get_gnupg_default_key (); |
127 |
if (defkey) |
if (defkey) |
128 |
err = gpg_keycache_find_key (kc, defkey, 0, &key); |
err = gpg_keycache_find_key (kc, defkey, 0, &key); |
129 |
|
else |
130 |
|
msg_box (NULL, _("No useable secret key found."), _("WinPT Error"), MB_ERR); |
131 |
free_if_alloc (defkey); |
free_if_alloc (defkey); |
132 |
return err? -1 : 0; |
return err? -1 : 0; |
133 |
} |
} |
188 |
return rc; |
return rc; |
189 |
} |
} |
190 |
/* We enable smartcard support for GPG: 1.9 or >= 1.4 */ |
/* We enable smartcard support for GPG: 1.9 or >= 1.4 */ |
191 |
if (ma >= 1 && mi >= 4) |
if ((ma == 1 && mi >= 4) || ma > 1) |
192 |
scard_support = 1; |
scard_support = 1; |
193 |
|
|
194 |
gpgver[0] = ma; |
gpgver[0] = ma; |
238 |
|
|
239 |
char* multi_gnupg_path (void); |
char* multi_gnupg_path (void); |
240 |
|
|
241 |
|
const char * fm_get_file_type (const char *fname, int *r_type); |
242 |
|
|
243 |
/* Main entry point. */ |
/* Main entry point. */ |
244 |
int WINAPI |
int WINAPI |
245 |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
246 |
{ |
{ |
247 |
WNDCLASS wc = {0, winpt_main_proc, 0, 0, hinst, 0, 0, 0, 0, PGM_NAME}; |
WNDCLASS wc = {0, winpt_main_proc, 0, 0, hinst, 0, 0, 0, 0, PGM_NAME}; |
248 |
HACCEL accel_tab; |
HACCEL accel_tab; |
249 |
int rc, ec, created = 0, use_cwd = 0, nfiles = 0; |
int rc, ec, created = 0, nfiles = 0; |
250 |
int first_start = 0, start_gpgprefs = 0; |
int first_start = 0, start_gpgprefs = 0; |
251 |
int winpt_inst_found = 0; |
int winpt_inst_found = 0; |
252 |
const char *s; |
const char *s; |
255 |
|
|
256 |
glob_hinst = hinst; |
glob_hinst = hinst; |
257 |
|
|
258 |
#ifdef _DEBUG |
#ifdef _DEBUG |
259 |
gpg_set_debug_mode (1); |
gpg_set_debug_mode (1); |
260 |
debug = 1; |
debug = 1; |
261 |
#endif |
#endif |
|
|
|
|
s = PTD_get_version (); |
|
|
if (strcmp (s, MIN_PTD_VER)) { |
|
|
log_box (_("Privacy Tray Dynamic (PTD)"), MB_ERR, |
|
|
_("Please update your PTD.dll to the newest version, " |
|
|
"the version (%s) you use is too old."), s); |
|
|
return 0; |
|
|
} |
|
262 |
|
|
263 |
if (gpg_md_selftest ()) { |
if (gpg_md_selftest ()) { |
264 |
msg_box (NULL, _("Cryptographic selftest failed."), |
msg_box (NULL, _("Cryptographic selftest failed."), |
302 |
get_reg_winpt_prefs (®_prefs); |
get_reg_winpt_prefs (®_prefs); |
303 |
if (!reg_prefs.no_hotkeys) |
if (!reg_prefs.no_hotkeys) |
304 |
hotkeys_modify (); |
hotkeys_modify (); |
305 |
|
gnupg_load_config (); |
306 |
} |
} |
307 |
|
|
308 |
rc = gnupg_check_homedir (); |
rc = gnupg_check_homedir (); |
311 |
_("GPG home directory is not set correctly.\n" |
_("GPG home directory is not set correctly.\n" |
312 |
"Please check the GPG registry settings:\n%s."), |
"Please check the GPG registry settings:\n%s."), |
313 |
winpt_strerror (rc)); |
winpt_strerror (rc)); |
314 |
const char * s = get_fileopen_dlg (GetActiveWindow (), |
s = get_fileopen_dlg (GetActiveWindow (), |
315 |
_("Select GPG Public Keyring"), |
_("Select GPG Public Keyring"), |
316 |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), |
317 |
NULL); |
NULL); |
318 |
if (s != NULL) { |
if (s != NULL) { |
319 |
size_t n; |
size_t n; |
320 |
char * p = strrchr (s, '\\'); |
char * p = strrchr (s, '\\'); |
390 |
|
|
391 |
if (cmdline && stristr (cmdline, "--wipe-freespace")) { |
if (cmdline && stristr (cmdline, "--wipe-freespace")) { |
392 |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_SPACE_SECDEL, |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_SPACE_SECDEL, |
393 |
GetDesktopWindow(), space_wipefrees_dlg_proc, NULL, |
GetDesktopWindow(), space_wipefrees_dlg_proc, 0, |
394 |
_("Wipe Free Space"), IDS_WINPT_SPACE_SECDEL); |
_("Wipe Free Space"), IDS_WINPT_SPACE_SECDEL); |
395 |
free_gnupg_table (); |
free_gnupg_table (); |
396 |
return 0; |
return 0; |
403 |
update_keycache (GetDesktopWindow ()); |
update_keycache (GetDesktopWindow ()); |
404 |
if (stristr (cmdline, "keymanager")) |
if (stristr (cmdline, "keymanager")) |
405 |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYMISC, |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_KEYMISC, |
406 |
GetDesktopWindow(), keymanager_dlg_proc, NULL, |
GetDesktopWindow(), keymanager_dlg_proc, 0, |
407 |
_("Key Manager"), IDS_WINPT_KEYMISC); |
_("Key Manager"), IDS_WINPT_KEYMISC); |
408 |
else { |
else { |
409 |
gpg_card_t crd = gpg_card_load (); |
gpg_card_t crd = gpg_card_load (); |
471 |
|
|
472 |
if (start_gpgprefs) { |
if (start_gpgprefs) { |
473 |
char *ring; |
char *ring; |
474 |
size_t size = 0; |
|
475 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
476 |
gpgprefs_dlg_proc, NULL); |
gpgprefs_dlg_proc, 0); |
477 |
ring = get_gnupg_keyring (0, !NO_STRICT); |
ring = get_gnupg_keyring (0, !NO_STRICT); |
478 |
if (gnupg_access_keyring (0) == -1 && get_file_size (ring) == 0) |
if (gnupg_access_keyring (0) == -1 && get_file_size (ring) == 0) |
479 |
first_start = 1; /* The keyring is empty! */ |
first_start = 1; /* The keyring is empty! */ |
487 |
start: |
start: |
488 |
h = GetDesktopWindow (); |
h = GetDesktopWindow (); |
489 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, h, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, h, |
490 |
gpgprefs_dlg_proc, NULL); |
gpgprefs_dlg_proc, 0); |
491 |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, h, |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, h, |
492 |
first_run_dlg_proc, (LPARAM)&fs); |
first_run_dlg_proc, (LPARAM)&fs); |
493 |
switch (fs.choice) { |
switch (fs.choice) { |
530 |
"WinPT", MB_INFO|MB_YESNO); |
"WinPT", MB_INFO|MB_YESNO); |
531 |
if (ec == IDYES) { |
if (ec == IDYES) { |
532 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
533 |
gpgprefs_dlg_proc, NULL); |
gpgprefs_dlg_proc, 0); |
534 |
update_keycache (hwnd); |
update_keycache (hwnd); |
535 |
} |
} |
536 |
else { |
else { |
552 |
} |
} |
553 |
if (count_insecure_elgkeys ()) |
if (count_insecure_elgkeys ()) |
554 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_ELGWARN, glob_hwnd, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_ELGWARN, glob_hwnd, |
555 |
elgamal_warn_dlg_proc, NULL); |
elgamal_warn_dlg_proc, 0); |
556 |
} |
} |
557 |
|
|
558 |
accel_tab = LoadAccelerators (glob_hinst, (LPCTSTR)IDR_WINPT_ACCELERATOR); |
accel_tab = LoadAccelerators (glob_hinst, (LPCTSTR)IDR_WINPT_ACCELERATOR); |