35 |
#include "wptContext.h" |
#include "wptContext.h" |
36 |
#include "wptCardEdit.h" |
#include "wptCardEdit.h" |
37 |
|
|
38 |
#define MIN_GPG_VER "1.4.3" |
|
39 |
|
#define MIN_GPG_VER "1.4.3" /* Minimal GPG version. */ |
40 |
|
#define MIN_GPGME_VER "1.2.0" /* Minimal GPGME version. */ |
41 |
|
|
42 |
|
|
43 |
HINSTANCE glob_hinst; /* global instance for the dialogs */ |
HINSTANCE glob_hinst; /* global instance for the dialogs */ |
44 |
HWND glob_hwnd; /* global window handle for the dialogs */ |
HWND glob_hwnd; /* global window handle for the dialogs */ |
74 |
putenv ("GPGME_DEBUG="); |
putenv ("GPGME_DEBUG="); |
75 |
} |
} |
76 |
|
|
77 |
static char * |
|
78 |
|
/* Return the name of the gettext language file. */ |
79 |
|
static char* |
80 |
get_gettext_lang (void) |
get_gettext_lang (void) |
81 |
{ |
{ |
82 |
char * fname; |
char *fname; |
83 |
fname = get_reg_entry_mo (); |
fname = get_reg_entry_mo (); |
84 |
if (!fname) |
if (!fname) |
85 |
return NULL; |
return NULL; |
86 |
return fname; |
return fname; |
87 |
} /* get_gettext_lang */ |
} |
88 |
|
|
89 |
|
|
90 |
|
/* Initialize the gettext sub system. */ |
91 |
static void |
static void |
92 |
load_gettext (void) |
load_gettext (void) |
93 |
{ |
{ |
106 |
free_if_alloc (nls); |
free_if_alloc (nls); |
107 |
free_if_alloc (file); |
free_if_alloc (file); |
108 |
} |
} |
109 |
} /* load_gettext */ |
} |
110 |
|
|
111 |
|
|
112 |
/* check if the default key from the gpg.conf file is available in the |
/* check if the default key from the gpg.conf file is available in the |
123 |
err = gpg_keycache_find_key (kc, defkey, 0, &key); |
err = gpg_keycache_find_key (kc, defkey, 0, &key); |
124 |
free_if_alloc (defkey); |
free_if_alloc (defkey); |
125 |
return err? -1 : 0; |
return err? -1 : 0; |
126 |
} /* check_default_key */ |
} |
127 |
|
|
128 |
|
|
129 |
/* Return the WinPT program file name (with full pathname). */ |
/* Return the WinPT program file name (with full pathname). */ |
155 |
_snprintf (program, DIM (program)-1, "%s\\%s", currdir + 1, fname); |
_snprintf (program, DIM (program)-1, "%s\\%s", currdir + 1, fname); |
156 |
} |
} |
157 |
return program; |
return program; |
158 |
} /* get_prog_part */ |
} |
159 |
|
|
160 |
|
|
161 |
|
/* Check that the underlying crypto engine fullfills the minimal |
162 |
|
requirements so all commands work properly. */ |
163 |
static int |
static int |
164 |
check_crypto_engine (void) |
check_crypto_engine (void) |
165 |
{ |
{ |
168 |
|
|
169 |
rc = check_gnupg_engine (&ma, &mi, &pa); |
rc = check_gnupg_engine (&ma, &mi, &pa); |
170 |
if (rc == -1) { |
if (rc == -1) { |
171 |
msg_box (NULL, _("Could not read GnuPG version."), _("WinPT Error"), MB_ERR); |
msg_box (NULL, _("Could not read GnuPG version."), |
172 |
|
_("WinPT Error"), MB_ERR); |
173 |
return rc; |
return rc; |
174 |
} |
} |
175 |
else if (rc) { |
else if (rc) { |
179 |
ma, mi, pa); |
ma, mi, pa); |
180 |
return rc; |
return rc; |
181 |
} |
} |
182 |
/* We enable smartcard support for GPG: 1.9.x or >= 1.4.0 */ |
/* We enable smartcard support for GPG: 1.9 or >= 1.4 */ |
183 |
if (ma >= 1 && mi >= 4) |
if (ma >= 1 && mi >= 4) |
184 |
scard_support = 1; |
scard_support = 1; |
185 |
|
|
187 |
gpgver[1] = mi; |
gpgver[1] = mi; |
188 |
gpgver[2] = pa; |
gpgver[2] = pa; |
189 |
return rc; |
return rc; |
190 |
} /* check_crypto_engine */ |
} |
191 |
|
|
192 |
|
|
193 |
|
/* Try to load the keyserver config file. If @quiet is 1 |
194 |
|
do not show any errors. */ |
195 |
static int |
static int |
196 |
load_keyserver_conf (int quiet) |
load_keyserver_conf (int quiet) |
197 |
{ |
{ |
227 |
reg_prefs.use_viewer = 0; /* XXX */ |
reg_prefs.use_viewer = 0; /* XXX */ |
228 |
} |
} |
229 |
|
|
|
char* get_subkey_fingerprint (gpgme_ctx_t ctx, const char *keyid); |
|
|
|
|
230 |
|
|
231 |
|
/* Main entry point. */ |
232 |
int WINAPI |
int WINAPI |
233 |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
WinMain (HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int showcmd) |
234 |
{ |
{ |
261 |
return 0; |
return 0; |
262 |
} |
} |
263 |
|
|
264 |
s = gpgme_check_version ("1.1.0"); |
s = gpgme_check_version (MIN_GPGME_VER); |
265 |
if (!s || !*s) { |
if (!s || !*s) { |
266 |
msg_box (NULL, _("A newer GPGME version is needed."), "WinPT Error", MB_ERR); |
msg_box (NULL, _("A newer GPGME version is needed; at least "MIN_GPGME_VER), |
267 |
|
_("WinPT Error"), MB_ERR); |
268 |
return 0; |
return 0; |
269 |
} |
} |
270 |
|
|
429 |
wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT)); |
wc.hIcon = LoadIcon (glob_hinst, MAKEINTRESOURCE (IDI_WINPT)); |
430 |
rc = RegisterClass (&wc); |
rc = RegisterClass (&wc); |
431 |
if (rc == FALSE) { |
if (rc == FALSE) { |
432 |
msg_box (NULL, _("Could not register window class"), _("WinPT Error"), MB_ERR); |
msg_box (NULL, _("Could not register window class"), |
433 |
|
_("WinPT Error"), MB_ERR); |
434 |
free_gnupg_table (); |
free_gnupg_table (); |
435 |
return 0; |
return 0; |
436 |
} |
} |
556 |
} |
} |
557 |
|
|
558 |
return 0; |
return 0; |
559 |
} /* WinMain */ |
} |