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. */ |
237 |
|
|
238 |
char* multi_gnupg_path (void); |
char* multi_gnupg_path (void); |
239 |
|
|
240 |
|
const char * fm_get_file_type (const char *fname, int *r_type); |
241 |
|
|
242 |
/* Main entry point. */ |
/* Main entry point. */ |
243 |
int WINAPI |
int WINAPI |
244 |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
245 |
{ |
{ |
246 |
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}; |
247 |
HACCEL accel_tab; |
HACCEL accel_tab; |
248 |
int rc, ec, created = 0, use_cwd = 0, nfiles = 0; |
int rc, ec, created = 0, nfiles = 0; |
249 |
int first_start = 0, start_gpgprefs = 0; |
int first_start = 0, start_gpgprefs = 0; |
250 |
int winpt_inst_found = 0; |
int winpt_inst_found = 0; |
251 |
const char *s; |
const char *s; |
260 |
#endif |
#endif |
261 |
|
|
262 |
s = PTD_get_version (); |
s = PTD_get_version (); |
263 |
if (strcmp (s, MIN_PTD_VER)) { |
// FIXME: Using strcmp here is wrong |
264 |
log_box (_("Privacy Tray Dynamic (PTD)"), MB_ERR, |
// if (strcmp (s, MIN_PTD_VER)) { |
265 |
_("Please update your PTD.dll to the newest version, " |
// log_box (_("Privacy Tray Dynamic (PTD)"), MB_ERR, |
266 |
"the version (%s) you use is too old."), s); |
// _("Please update your PTD.dll to the newest version, " |
267 |
return 0; |
// "the version (%s) you use is too old."), s); |
268 |
} |
// return 0; |
269 |
|
// } |
270 |
|
|
271 |
if (gpg_md_selftest ()) { |
if (gpg_md_selftest ()) { |
272 |
msg_box (NULL, _("Cryptographic selftest failed."), |
msg_box (NULL, _("Cryptographic selftest failed."), |
310 |
get_reg_winpt_prefs (®_prefs); |
get_reg_winpt_prefs (®_prefs); |
311 |
if (!reg_prefs.no_hotkeys) |
if (!reg_prefs.no_hotkeys) |
312 |
hotkeys_modify (); |
hotkeys_modify (); |
313 |
|
gnupg_load_config (); |
314 |
} |
} |
315 |
|
|
316 |
rc = gnupg_check_homedir (); |
rc = gnupg_check_homedir (); |
319 |
_("GPG home directory is not set correctly.\n" |
_("GPG home directory is not set correctly.\n" |
320 |
"Please check the GPG registry settings:\n%s."), |
"Please check the GPG registry settings:\n%s."), |
321 |
winpt_strerror (rc)); |
winpt_strerror (rc)); |
322 |
const char * s = get_fileopen_dlg (GetActiveWindow (), |
s = get_fileopen_dlg (GetActiveWindow (), |
323 |
_("Select GPG Public Keyring"), |
_("Select GPG Public Keyring"), |
324 |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), |
325 |
NULL); |
NULL); |
326 |
if (s != NULL) { |
if (s != NULL) { |
327 |
size_t n; |
size_t n; |
328 |
char * p = strrchr (s, '\\'); |
char * p = strrchr (s, '\\'); |
479 |
|
|
480 |
if (start_gpgprefs) { |
if (start_gpgprefs) { |
481 |
char *ring; |
char *ring; |
482 |
size_t size = 0; |
|
483 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
484 |
gpgprefs_dlg_proc, NULL); |
gpgprefs_dlg_proc, 0); |
485 |
ring = get_gnupg_keyring (0, !NO_STRICT); |
ring = get_gnupg_keyring (0, !NO_STRICT); |
486 |
if (gnupg_access_keyring (0) == -1 && get_file_size (ring) == 0) |
if (gnupg_access_keyring (0) == -1 && get_file_size (ring) == 0) |
487 |
first_start = 1; /* The keyring is empty! */ |
first_start = 1; /* The keyring is empty! */ |
495 |
start: |
start: |
496 |
h = GetDesktopWindow (); |
h = GetDesktopWindow (); |
497 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, h, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, h, |
498 |
gpgprefs_dlg_proc, NULL); |
gpgprefs_dlg_proc, 0); |
499 |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, h, |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, h, |
500 |
first_run_dlg_proc, (LPARAM)&fs); |
first_run_dlg_proc, (LPARAM)&fs); |
501 |
switch (fs.choice) { |
switch (fs.choice) { |
538 |
"WinPT", MB_INFO|MB_YESNO); |
"WinPT", MB_INFO|MB_YESNO); |
539 |
if (ec == IDYES) { |
if (ec == IDYES) { |
540 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
541 |
gpgprefs_dlg_proc, NULL); |
gpgprefs_dlg_proc, 0); |
542 |
update_keycache (hwnd); |
update_keycache (hwnd); |
543 |
} |
} |
544 |
else { |
else { |
560 |
} |
} |
561 |
if (count_insecure_elgkeys ()) |
if (count_insecure_elgkeys ()) |
562 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_ELGWARN, glob_hwnd, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_ELGWARN, glob_hwnd, |
563 |
elgamal_warn_dlg_proc, NULL); |
elgamal_warn_dlg_proc, 0); |
564 |
} |
} |
565 |
|
|
566 |
accel_tab = LoadAccelerators (glob_hinst, (LPCTSTR)IDR_WINPT_ACCELERATOR); |
accel_tab = LoadAccelerators (glob_hinst, (LPCTSTR)IDR_WINPT_ACCELERATOR); |