diff options
Diffstat (limited to 'gpgme/keylist.c')
-rw-r--r-- | gpgme/keylist.c | 81 |
1 files changed, 35 insertions, 46 deletions
diff --git a/gpgme/keylist.c b/gpgme/keylist.c index ebdb707a..2685f4f6 100644 --- a/gpgme/keylist.c +++ b/gpgme/keylist.c @@ -383,62 +383,51 @@ finish_key ( GpgmeCtx ctx ) * Return value: 0 on success or an errorcode. **/ GpgmeError -gpgme_op_keylist_start ( GpgmeCtx c, const char *pattern, int secret_only ) +gpgme_op_keylist_start (GpgmeCtx ctx, const char *pattern, int secret_only) { - GpgmeError rc = 0; - int i; + GpgmeError err = 0; - if ( !c ) - return mk_error (Invalid_Value); - c->pending = 1; + if (!ctx) + return mk_error (Invalid_Value); + ctx->pending = 1; - _gpgme_release_result (c); - c->out_of_core = 0; + _gpgme_release_result (ctx); + ctx->out_of_core = 0; - if ( c->gpg ) { - _gpgme_gpg_release ( c->gpg ); - c->gpg = NULL; + if (ctx->engine) + { + _gpgme_engine_release (ctx->engine); + ctx->engine = NULL; } - gpgme_key_release (c->tmp_key); - c->tmp_key = NULL; - /* Fixme: release key_queue */ - - rc = _gpgme_gpg_new ( &c->gpg ); - if (rc) - goto leave; - - _gpgme_gpg_set_status_handler ( c->gpg, keylist_status_handler, c ); - - rc = _gpgme_gpg_set_colon_line_handler ( c->gpg, - keylist_colon_handler, c ); - if (rc) - goto leave; - - /* build the commandline */ - for ( i=0; i < c->verbosity; i++ ) - _gpgme_gpg_add_arg ( c->gpg, "--verbose" ); - _gpgme_gpg_add_arg ( c->gpg, "--with-colons" ); - _gpgme_gpg_add_arg ( c->gpg, "--fixed-list-mode" ); - _gpgme_gpg_add_arg ( c->gpg, "--with-fingerprint" ); - if (c->keylist_mode == 1) - _gpgme_gpg_add_arg ( c->gpg, "--no-expensive-trust-checks" ); - _gpgme_gpg_add_arg ( c->gpg, secret_only? - "--list-secret-keys":"--list-keys" ); + gpgme_key_release (ctx->tmp_key); + ctx->tmp_key = NULL; + /* Fixme: Release key_queue. */ - /* Tell the gpg object about the data */ - _gpgme_gpg_add_arg ( c->gpg, "--" ); - if (pattern && *pattern) - _gpgme_gpg_add_arg ( c->gpg, pattern ); + err = _gpgme_engine_new (ctx->use_cms ? GPGME_PROTOCOL_CMS + : GPGME_PROTOCOL_OpenPGP, &ctx->engine); + if (err) + goto leave; + + _gpgme_engine_set_status_handler (ctx->engine, keylist_status_handler, ctx); + err = _gpgme_engine_set_colon_line_handler (ctx->engine, + keylist_colon_handler, ctx); + if (err) + goto leave; + _gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity); + + err = _gpgme_engine_op_keylist (ctx->engine, pattern, secret_only, ctx->keylist_mode); - /* and kick off the process */ - rc = _gpgme_gpg_spawn ( c->gpg, c ); + if (!err) /* And kick off the process. */ + err = _gpgme_engine_start (ctx->engine, ctx); leave: - if (rc) { - c->pending = 0; - _gpgme_gpg_release ( c->gpg ); c->gpg = NULL; + if (err) + { + ctx->pending = 0; + _gpgme_engine_release (ctx->engine); + ctx->engine = NULL; } - return rc; + return err; } |