1 /* delete.c - delete a key
2 * Copyright (C) 2001 g10 Code GmbH
4 * This file is part of GPGME.
6 * GPGME is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * GPGME is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
34 delete_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
36 if ( ctx->out_of_core )
44 /* ignore all other codes */
51 gpgme_op_delete_start ( GpgmeCtx c, const GpgmeKey key, int allow_secret )
57 fail_on_pending_request( c );
61 rc = mk_error (Invalid_Value);
66 _gpgme_gpg_release ( c->gpg );
70 rc = _gpgme_gpg_new ( &c->gpg );
74 _gpgme_gpg_set_status_handler ( c->gpg, delete_status_handler, c );
76 /* build the commandline */
77 for ( i=0; i < c->verbosity; i++ )
78 _gpgme_gpg_add_arg ( c->gpg, "--verbose" );
79 _gpgme_gpg_add_arg ( c->gpg, allow_secret?
80 "--delete-secret-and-public-key":"--delete-key" );
82 _gpgme_gpg_add_arg ( c->gpg, "--" );
83 s = gpgme_key_get_string_attr ( key, GPGME_ATTR_FPR, NULL, 0 );
85 rc = mk_error (Invalid_Key);
88 _gpgme_gpg_add_arg ( c->gpg, s );
91 rc = _gpgme_gpg_spawn ( c->gpg, c );
96 _gpgme_gpg_release ( c->gpg ); c->gpg = NULL;
103 gpgme_op_delete ( GpgmeCtx c, const GpgmeKey key, int allow_secret )
105 int rc = gpgme_op_delete_start ( c, key, allow_secret );
109 /* FIXME: check for success */