1 |
/* WinPT.cpp - Windows Privacy Tray (WinPT) |
/* WinPT.cpp - Windows Privacy Tray (WinPT) |
2 |
* Copyright (C) 2000-2005 Timo Schulz |
* Copyright (C) 2000-2006 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
156 |
return 0; |
return 0; |
157 |
} |
} |
158 |
|
|
159 |
|
|
160 |
/* 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 |
161 |
keyring. if not, bail out because encryption won't work properly then. */ |
keyring. if not, bail out because encryption won't work properly then. */ |
162 |
static int |
static int |
263 |
} |
} |
264 |
|
|
265 |
|
|
266 |
|
/* Check if both keyrings are empty. This indicates that |
267 |
|
WinPT should offer to generate a key pair. */ |
268 |
|
static bool |
269 |
|
check_for_empty_keyrings (bool pub_only) |
270 |
|
{ |
271 |
|
char *p; |
272 |
|
int n = 0; |
273 |
|
|
274 |
|
p = get_gnupg_keyring (1, 0); |
275 |
|
if (file_exist_check (p) == 0 && get_file_size (p) == 0) |
276 |
|
n++; |
277 |
|
free_if_alloc (p); |
278 |
|
if (pub_only) |
279 |
|
return n == 1? true : false; |
280 |
|
p = get_gnupg_keyring (0, 0); |
281 |
|
if (file_exist_check (p) == 0 && get_file_size (p) == 0) |
282 |
|
n++; |
283 |
|
free_if_alloc (p); |
284 |
|
return n==2? true : false; |
285 |
|
} |
286 |
|
|
287 |
|
|
288 |
/* Enable the mobility mode. */ |
/* Enable the mobility mode. */ |
289 |
static void |
static void |
290 |
enable_mobile_mode (void) |
enable_mobile_mode (void) |
468 |
return 0; |
return 0; |
469 |
} |
} |
470 |
} |
} |
471 |
|
if (check_for_empty_keyrings (false)) |
472 |
|
first_start = 1; |
473 |
|
|
474 |
if (!first_start) { |
if (!first_start) { |
475 |
rc = gpg_check_permissions (1); |
rc = gpg_check_permissions (1); |
564 |
} |
} |
565 |
|
|
566 |
if (start_gpgprefs) { |
if (start_gpgprefs) { |
|
char *ring; |
|
567 |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
DialogBoxParam (glob_hinst, (LPCTSTR)IDD_WINPT_GPGPREFS, hwnd, |
568 |
gpgprefs_dlg_proc, 0); |
gpgprefs_dlg_proc, 0); |
569 |
ring = get_gnupg_keyring (0, !NO_STRICT); |
if (check_for_empty_keyrings (true)) |
570 |
if (gnupg_access_keyring (0) == -1 && get_file_size (ring) == 0) |
first_start = 1; /* The public keyring is empty! */ |
|
first_start = 1; /* The keyring is empty! */ |
|
|
free_if_alloc (ring); |
|
571 |
} |
} |
572 |
|
|
573 |
if (first_start) { |
if (first_start) { |
598 |
} |
} |
599 |
break; |
break; |
600 |
|
|
601 |
case -1: |
case -1: /* Cancel/Abort. */ |
602 |
DestroyWindow (hwnd); |
DestroyWindow (hwnd); |
603 |
free_gnupg_table (); |
free_gnupg_table (); |
604 |
return 0; |
return 0; |