161 |
* appended string 'gpg.exe' is used. |
* appended string 'gpg.exe' is used. |
162 |
*/ |
*/ |
163 |
char* |
char* |
164 |
get_gnupg_prog( void ) |
get_gnupg_prog (void) |
165 |
{ |
{ |
166 |
char *p, *path, *pgm = NULL; |
char *p, *path, *pgm = NULL; |
167 |
size_t nlen = 0; |
size_t nlen = 0; |
193 |
if (!sec) |
if (!sec) |
194 |
BUG (0); |
BUG (0); |
195 |
gpgme_keycache_rewind (sec); |
gpgme_keycache_rewind (sec); |
196 |
while (!gpgme_keycache_next_key (sec, 1, &key)) |
while (!gpgme_keycache_next_key (sec, 1, &key)) { |
197 |
{ |
if (key_is_useable (key)) { |
198 |
if (gpgme_key_get_ulong_attr (key, GPGME_ATTR_KEY_USABLE, NULL, 0)) |
s = key->subkeys->keyid; |
|
{ |
|
|
s = gpgme_key_get_string_attr (key, GPGME_ATTR_KEYID, NULL, 0); |
|
199 |
if (s) |
if (s) |
200 |
keyid = m_strdup (s+8); |
keyid = m_strdup (s+8); |
201 |
break; |
break; |
202 |
} |
} |
203 |
} |
} |
204 |
if (!keyid) |
if (!keyid) { |
|
{ |
|
205 |
*ret_no_useable = 1; |
*ret_no_useable = 1; |
206 |
msg_box( NULL, _("No useable secret key found."), _("GPG Error"), MB_ERR); |
msg_box( NULL, _("No useable secret key found."), _("GPG Error"), MB_ERR); |
207 |
} |
} |
299 |
int |
int |
300 |
check_gnupg_engine (int * r_major, int * r_minor, int * r_patch) |
check_gnupg_engine (int * r_major, int * r_minor, int * r_patch) |
301 |
{ |
{ |
302 |
gpgme_error_t err; |
gpgme_ctx_t ctx; |
303 |
|
gpgme_engine_info_t inf; |
304 |
char * eng = NULL; |
char * eng = NULL; |
305 |
int major=0, minor=0, patch=0; |
int major=0, minor=0, patch=0; |
306 |
int rc; |
int rc; |
307 |
|
|
308 |
err = gpgme_op_version( &eng ); |
gpgme_new (&ctx); |
309 |
if( err ) |
inf = gpgme_ctx_get_engine_info (ctx); |
310 |
|
if (!inf) { |
311 |
|
gpgme_release (ctx); |
312 |
return -1; |
return -1; |
313 |
|
} |
314 |
if( strstr( eng, "IDEA" ) ) |
if( strstr( eng, "IDEA" ) ) |
315 |
idea_available = 1; |
idea_available = 1; |
316 |
rc = parse_version_nr( eng, &major, &minor, &patch ); |
rc = parse_version_nr( inf->version, &major, &minor, &patch ); |
317 |
free( eng ); eng = NULL; |
if( rc ) { |
318 |
if( rc ) |
gpgme_release (ctx); |
319 |
return rc; |
return rc; |
320 |
|
} |
321 |
if( major < *r_major |
if( major < *r_major |
322 |
|| minor < *r_minor) |
|| minor < *r_minor) |
323 |
rc = 1; |
rc = 1; |
902 |
|
|
903 |
|
|
904 |
void |
void |
905 |
gnupg_backup_options (int keep) |
gnupg_backup_options (void) |
906 |
{ |
{ |
907 |
char *optfile = NULL; |
char *cfgfile = NULL; |
908 |
char bak[1024]; |
char bak[512]; |
909 |
|
|
910 |
optfile = get_gnupg_cfgfile (); |
cfgfile = get_gnupg_cfgfile (); |
911 |
if (optfile == NULL) |
if (cfgfile == NULL) |
912 |
return; |
return; |
913 |
if (keep) |
_snprintf (bak, DIM (bak)-1, "%s.bak", cfgfile); |
914 |
_snprintf (bak, DIM (bak)-1, "%s.old", optfile); |
CopyFile (cfgfile, bak, FALSE); |
915 |
else |
free_if_alloc (cfgfile); |
|
_snprintf (bak, DIM (bak)-1, "%s.O", optfile); |
|
|
CopyFile (optfile, bak, keep); |
|
|
free_if_alloc (optfile); |
|
916 |
} /* gnupg_backup_options */ |
} /* gnupg_backup_options */ |
917 |
|
|
918 |
|
|