1 |
/* wptGPG.cpp - GnuPG configuration |
/* wptGPG.cpp - GnuPG configuration |
2 |
* Copyright (C) 2001-2004 Timo Schulz |
* Copyright (C) 2001-2005 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
17 |
* along with WinPT; if not, write to the Free Software Foundation, |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
*/ |
*/ |
|
|
|
20 |
#ifdef HAVE_CONFIG_H |
#ifdef HAVE_CONFIG_H |
21 |
#include <config.h> |
#include <config.h> |
22 |
#endif |
#endif |
23 |
|
|
24 |
#include <string.h> |
#include <windows.h> |
25 |
|
#include <shlobj.h> |
26 |
#include <string.h> |
#include <string.h> |
27 |
#include <stdio.h> |
#include <stdio.h> |
|
#include <windows.h> |
|
28 |
#include <shlobj.h> |
#include <shlobj.h> |
29 |
#include <ctype.h> |
#include <ctype.h> |
30 |
#include <io.h> |
#include <io.h> |
31 |
|
#include <time.h> |
32 |
|
|
33 |
#include "wptGPG.h" |
#include "wptGPG.h" |
34 |
#include "wptGPGCmds.h" |
#include "wptGpgCmds.h" |
35 |
#include "wptGPGOptSkel.h" |
#include "wptGPGOptSkel.h" |
36 |
#include "wptTypes.h" |
#include "wptTypes.h" |
37 |
#include "wptNLS.h" |
#include "wptNLS.h" |
170 |
/* Return the full path (with the gpg exe name). First the registry is scanned |
/* Return the full path (with the gpg exe name). First the registry is scanned |
171 |
for the entry 'gpgProgram'. If it wasn't set, the default path is the |
for the entry 'gpgProgram'. If it wasn't set, the default path is the |
172 |
appended string 'gpg.exe' is used. */ |
appended string 'gpg.exe' is used. */ |
173 |
|
|
174 |
|
/* FIXME: Use gpgme's engine info here. */ |
175 |
char* |
char* |
176 |
get_gnupg_prog (void) |
get_gnupg_prog (void) |
177 |
{ |
{ |
225 |
} |
} |
226 |
|
|
227 |
|
|
228 |
|
/* Load the gpg.conf and search for some options |
229 |
|
and store the result in the global preference context. |
230 |
|
Return value: 0 on success. */ |
231 |
|
int |
232 |
|
gnupg_load_config (void) |
233 |
|
{ |
234 |
|
int rc; |
235 |
|
gpg_optfile_t opt; |
236 |
|
gpg_option_t o; |
237 |
|
char *conf = get_gnupg_cfgfile (); |
238 |
|
if (!conf) |
239 |
|
return -1; |
240 |
|
rc = parse_gpg_options (conf, &opt); |
241 |
|
if (rc) { |
242 |
|
free_if_alloc (conf); |
243 |
|
return -1; |
244 |
|
} |
245 |
|
o = find_option (opt, "ask-cert-level"); |
246 |
|
if (o) |
247 |
|
reg_prefs.gpg.ask_cert_level = 1; |
248 |
|
release_gpg_options (opt); |
249 |
|
free_if_alloc (conf); |
250 |
|
return 0; |
251 |
|
} |
252 |
|
|
253 |
|
|
254 |
char* |
char* |
255 |
get_gnupg_default_key (void) |
get_gnupg_default_key (void) |
256 |
{ |
{ |
280 |
if( e ) |
if( e ) |
281 |
keyid = m_strdup( e->val ); |
keyid = m_strdup( e->val ); |
282 |
} |
} |
283 |
free_if_alloc( optfile ); |
free_if_alloc (optfile); |
284 |
release_gpg_options( opt ); |
release_gpg_options (opt); |
285 |
|
|
286 |
if( !keyid ) |
if (!keyid) |
287 |
keyid = default_key_from_cache( &no_usable ); |
keyid = default_key_from_cache (&no_usable); |
288 |
return keyid; |
return keyid; |
289 |
} /* get_gnupg_default_key */ |
} /* get_gnupg_default_key */ |
290 |
|
|
360 |
gpgme_release (ctx); |
gpgme_release (ctx); |
361 |
return rc; |
return rc; |
362 |
} |
} |
363 |
|
|
364 |
|
/* FIXME: This check is wrong! */ |
365 |
if (major < *r_major || minor < *r_minor) |
if (major < *r_major || minor < *r_minor) |
366 |
rc = 1; |
rc = 1; |
367 |
else { |
else { |