22 |
#endif |
#endif |
23 |
|
|
24 |
#include <windows.h> |
#include <windows.h> |
25 |
|
#include <shlobj.h> |
26 |
|
|
27 |
#include "resource.h" |
#include "resource.h" |
28 |
#include "wptTypes.h" |
#include "wptTypes.h" |
41 |
#include "wptCardEdit.h" |
#include "wptCardEdit.h" |
42 |
#include "wptCrypto.h" |
#include "wptCrypto.h" |
43 |
|
|
44 |
|
|
45 |
HINSTANCE glob_hinst; /* global instance for the dialogs */ |
HINSTANCE glob_hinst; /* global instance for the dialogs */ |
46 |
HWND glob_hwnd; /* global window handle for the dialogs */ |
HWND glob_hwnd; /* global window handle for the dialogs */ |
47 |
HWND activ_hwnd; |
HWND activ_hwnd; |
220 |
return false; |
return false; |
221 |
} |
} |
222 |
/* We enable smartcard support for GPG: >= 2 or >= 1.4.3 */ |
/* We enable smartcard support for GPG: >= 2 or >= 1.4.3 */ |
223 |
if (ma > 1 || pa >= 3) |
if (ma > 1 || pa >= 3) |
224 |
scard_support = 1; |
scard_support = 1; |
225 |
|
|
226 |
gpgver[0] = ma; |
gpgver[0] = ma; |
235 |
static int |
static int |
236 |
load_keyserver_conf (int quiet) |
load_keyserver_conf (int quiet) |
237 |
{ |
{ |
238 |
|
char *buf; |
239 |
const char *t; |
const char *t; |
240 |
int rc; |
int rc; |
241 |
|
|
242 |
if (reg_prefs.kserv_conf) |
/* Create $APPDATA\winpt if needed. */ |
243 |
t = reg_prefs.kserv_conf; |
buf = make_special_filename (CSIDL_APPDATA, "winpt", NULL); |
244 |
else if (!file_exist_check (get_prog_part ("keyserver.conf", 0))) |
if (buf && dir_exist_check (buf) && !CreateDirectory (buf, NULL)) { |
245 |
|
MessageBox (NULL, _("Failed to create WinPT directory"), |
246 |
|
_("Keyserver"), MB_ERR); |
247 |
|
free_if_alloc (buf); |
248 |
|
return -1; |
249 |
|
} |
250 |
|
free_if_alloc (buf); |
251 |
|
|
252 |
|
/* Check for $APPDATA\winpt\keyserver.conf */ |
253 |
|
buf = make_special_filename (CSIDL_APPDATA, "winpt\\keyserver.conf", NULL); |
254 |
|
|
255 |
|
if (!file_exist_check (get_prog_part ("keyserver.conf", 0))) |
256 |
t = get_prog_part ("keyserver.conf", 0); |
t = get_prog_part ("keyserver.conf", 0); |
257 |
else |
else |
258 |
t = "keyserver.conf"; |
t = "keyserver.conf"; |
259 |
|
if (file_exist_check (t) == 0 && file_exist_check (buf) != 0) { |
260 |
|
//log_box (_("Keyserver"), MB_INFO, |
261 |
|
// _("keyserver.conf will be copied to \"%s\"\r\n"), buf); |
262 |
|
if (!CopyFile (t, buf, FALSE)) { |
263 |
|
MessageBox (NULL, _("Failed to copy the keyserver.conf"), |
264 |
|
_("Keyserver"), MB_ERR); |
265 |
|
free_if_alloc (buf); |
266 |
|
return -1; |
267 |
|
} |
268 |
|
t = buf; |
269 |
|
} |
270 |
|
else |
271 |
|
t = buf; |
272 |
|
|
273 |
rc = kserver_load_conf (t); |
rc = kserver_load_conf (t); |
274 |
if (rc && !quiet) |
if (rc && !quiet) |
275 |
msg_box (NULL, winpt_strerror (rc), _("Keyserver"), MB_ERR); |
msg_box (NULL, winpt_strerror (rc), _("Keyserver"), MB_ERR); |
276 |
|
else { |
277 |
|
free_if_alloc (reg_prefs.kserv_conf); |
278 |
|
reg_prefs.kserv_conf = m_strdup (t); |
279 |
|
} |
280 |
|
free_if_alloc (buf); |
281 |
return rc; |
return rc; |
282 |
} |
} |
283 |
|
|