33 |
#include "wptCard.h" |
#include "wptCard.h" |
34 |
#include "wptFileManager.h" |
#include "wptFileManager.h" |
35 |
#include "wptContext.h" |
#include "wptContext.h" |
36 |
|
#include "wptCardEdit.h" |
37 |
|
|
38 |
HINSTANCE glob_hinst; /* global instance for the dialogs */ |
HINSTANCE glob_hinst; /* global instance for the dialogs */ |
39 |
HWND glob_hwnd; /* global window handle for the dialogs */ |
HWND glob_hwnd; /* global window handle for the dialogs */ |
60 |
} /* update_keycache */ |
} /* update_keycache */ |
61 |
|
|
62 |
|
|
63 |
|
/* Set GPGME debug mode. If @val is 0, the debug mode is disabled. */ |
64 |
|
void |
65 |
|
gpg_set_debug_mode (int val) |
66 |
|
{ |
67 |
|
if (val) |
68 |
|
putenv ("GPGME_DEBUG=5:gpgme.dbg"); |
69 |
|
else |
70 |
|
putenv ("GPGME_DEBUG="); |
71 |
|
} |
72 |
|
|
73 |
static char * |
static char * |
74 |
get_gettext_lang (void) |
get_gettext_lang (void) |
75 |
{ |
{ |
84 |
static void |
static void |
85 |
load_gettext (void) |
load_gettext (void) |
86 |
{ |
{ |
87 |
char * nls = NULL; |
char *nls = NULL; |
88 |
char * file = NULL; |
char *file = NULL; |
89 |
|
|
90 |
nls = get_gettext_lang (); |
nls = get_gettext_lang (); |
91 |
if (nls) { |
if (nls) { |
108 |
check_default_key (gpgme_keycache_t kc) |
check_default_key (gpgme_keycache_t kc) |
109 |
{ |
{ |
110 |
gpgme_key_t key; |
gpgme_key_t key; |
111 |
gpgme_error_t err = GPGME_No_Error; |
gpgme_error_t err = GPG_ERR_NO_ERROR; |
112 |
char * defkey; |
char * defkey; |
113 |
|
|
114 |
defkey = get_gnupg_default_key (); |
defkey = get_gnupg_default_key (); |
230 |
int first_start = 0, start_gpgprefs = 0; |
int first_start = 0, start_gpgprefs = 0; |
231 |
const char * s; |
const char * s; |
232 |
MSG msg; |
MSG msg; |
233 |
HWND hwnd; |
HWND hwnd = NULL; |
234 |
|
|
235 |
glob_hinst = hinst; |
glob_hinst = hinst; |
236 |
|
|
|
gpgme_lib_init (); |
|
237 |
#ifdef _DEBUG |
#ifdef _DEBUG |
238 |
gpgme_set_debug_mode (1); |
gpg_set_debug_mode (1); |
239 |
|
debug = 1; |
240 |
#endif |
#endif |
|
gpgme_set_pgm_string ("WinPT "PGM_VERSION); |
|
241 |
|
|
242 |
s = PTD_get_version (); |
s = PTD_get_version (); |
243 |
if (strcmp (s, "0.8.0")) { |
if (strcmp (s, "0.8.0")) { |
253 |
return 0; |
return 0; |
254 |
} |
} |
255 |
|
|
256 |
|
s = gpgme_check_version ("1.1.0"); |
257 |
|
if (!s || !*s) { |
258 |
|
msg_box (NULL, _("A newer GPGME version is needed."), "WinPT Error", MB_ERR); |
259 |
|
return 0; |
260 |
|
} |
261 |
|
|
262 |
if (cmdline && stristr (cmdline, "--mobile")) { |
if (cmdline && stristr (cmdline, "--mobile")) { |
263 |
msg_box (NULL, "WARNING: mobile modus is not fully implemented yet!", "WinPT", MB_INFO); |
msg_box (NULL, "WARNING: mobile modus is not fully implemented yet!", |
264 |
|
"WinPT", MB_INFO); |
265 |
mobile = 1; |
mobile = 1; |
266 |
} |
} |
267 |
|
|
296 |
_("Select GPG Public Keyring"), |
_("Select GPG Public Keyring"), |
297 |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), |
_("GPG Keyrings (*.gpg)\0*.gpg\0\0"), |
298 |
NULL); |
NULL); |
299 |
if (s && !file_exist_check (s)) |
if (s != NULL) { |
|
{ |
|
300 |
size_t n; |
size_t n; |
301 |
char * p = strrchr (s, '\\'); |
char * p = strrchr (s, '\\'); |
302 |
if (!p) |
if (!p) |
398 |
GetDesktopWindow(), keymanager_dlg_proc, NULL, |
GetDesktopWindow(), keymanager_dlg_proc, NULL, |
399 |
_("Key Manager"), IDS_WINPT_KEYMISC); |
_("Key Manager"), IDS_WINPT_KEYMISC); |
400 |
else { |
else { |
401 |
gpgme_card_t crd = smartcard_init (); |
gpg_card_t crd = smartcard_init (); |
402 |
if (crd) |
if (crd) |
403 |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_CARD_EDIT, |
dialog_box_param (glob_hinst, (LPCTSTR)IDD_WINPT_CARD_EDIT, |
404 |
GetDesktopWindow(), card_edit_dlg_proc, |
GetDesktopWindow(), card_edit_dlg_proc, |
405 |
(LPARAM)crd, _("Card Manager"), |
(LPARAM)crd, _("Card Manager"), |
406 |
IDS_WINPT_CARD_EDIT); |
IDS_WINPT_CARD_EDIT); |
407 |
gpgme_card_release (crd); |
gpg_card_release (crd); |
408 |
} |
} |
409 |
keycache_release (); |
keycache_release (); |
410 |
free_gnupg_table (); |
free_gnupg_table (); |
419 |
|
|
420 |
if (cmdline) { |
if (cmdline) { |
421 |
if (stristr (cmdline, "--enable-debug") || stristr (cmdline, "--debug")) { |
if (stristr (cmdline, "--enable-debug") || stristr (cmdline, "--debug")) { |
422 |
gpgme_set_debug_mode (1); |
gpg_set_debug_mode (1); |
423 |
winpt_debug_msg (); |
winpt_debug_msg (); |
424 |
debug = 1; |
debug = 1; |
425 |
} |
} |
449 |
UpdateWindow (hwnd); |
UpdateWindow (hwnd); |
450 |
|
|
451 |
if (!first_start && !start_gpgprefs) { |
if (!first_start && !start_gpgprefs) { |
452 |
gnupg_backup_options (1); |
gnupg_backup_options (); |
|
gnupg_backup_options (0); |
|
|
|
|
453 |
rc = check_crypto_engine (); |
rc = check_crypto_engine (); |
454 |
if (rc) { |
if (rc) { |
455 |
DestroyWindow (hwnd); |
DestroyWindow (hwnd); |
457 |
return 0; |
return 0; |
458 |
} |
} |
459 |
} |
} |
460 |
|
|
461 |
if (start_gpgprefs) |
if (start_gpgprefs) { |
|
{ |
|
462 |
char *ring; |
char *ring; |
463 |
size_t size = 0; |
size_t size = 0; |
464 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
470 |
} |
} |
471 |
|
|
472 |
if (first_start) { |
if (first_start) { |
473 |
struct key_wizard_s c, dummy; |
struct first_start_s fs; |
474 |
|
struct genkey_s c; |
475 |
|
HWND h; |
476 |
start: |
start: |
477 |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, hwnd, |
h = GetDesktopWindow (); |
478 |
first_run_dlg_proc, (LPARAM)&dummy); |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, h, |
479 |
switch (dummy.interactive) |
gpgprefs_dlg_proc, NULL); |
480 |
{ |
DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_FIRST, h, |
481 |
|
first_run_dlg_proc, (LPARAM)&fs); |
482 |
|
switch (fs.choice) { |
483 |
case SETUP_KEYGEN: |
case SETUP_KEYGEN: |
484 |
c.interactive = 1; |
c.interactive = 1; |
485 |
|
c.first_start = 1; |
486 |
rc = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYWIZARD, |
rc = DialogBoxParam (glob_hinst, (LPCSTR)IDD_WINPT_KEYWIZARD, |
487 |
hwnd, keygen_wizard_dlg_proc, (LPARAM)&c); |
h, keygen_wizard_dlg_proc, (LPARAM)&c); |
488 |
if (!rc) |
if (!rc) |
489 |
goto start; |
goto start; |
490 |
break; |
break; |
497 |
} |
} |
498 |
break; |
break; |
499 |
|
|
|
case SETUP_EXISTING: |
|
|
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
|
|
gpgprefs_dlg_proc, NULL); |
|
|
break; |
|
|
|
|
500 |
case -1: |
case -1: |
501 |
DestroyWindow (hwnd); |
DestroyWindow (hwnd); |
502 |
free_gnupg_table (); |
free_gnupg_table (); |