From: Marcus Brinkmann Date: Thu, 31 Jan 2002 00:31:44 +0000 (+0000) Subject: doc/ X-Git-Tag: gpgme-1.2.0@1385~1117 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6ef4854e33feea06e5ad5dc0440cb89b36ae1fbb;p=gpgme.git doc/ 2002-01-31 Marcus Brinkmann * gpgme.texi (Generating Keys): Document error at creation failure. gpgme/ 2002-01-31 Marcus Brinkmann * rungpg.h: Add STATUS_KEY_CREATED. * progress.c: New file. * Makefile.am (libgpgme_la_SOURCES): Add progress.c. * genkey.c (genkey_status_handler): Use _gpgme_progress_status_handler. Add check for status. (struct genkey_result_s): New structure. (_gpgme_release_genkey_result): New function. (gpgme_op_genkey): Check for error. * gpgme.c (_gpgme_release_result): Call _gpgme_release_genkey_result. * ops.h (_gpgme_release_genkey_result): Add prototype. * types.h (GenKeyResult): New type. * context.h (gpgme_context_s): Add GenKeyResult to member result. --- diff --git a/trunk/TODO b/trunk/TODO index 9f09b41..1a840f7 100644 --- a/trunk/TODO +++ b/trunk/TODO @@ -35,7 +35,9 @@ (it's an internal error, as select_protocol checks already). * Operations -** Import, export, genkey, delete status handler need much more work. +** Export status handler need much more work. +** Import should return a useful error when one happened. +** Genkey should return something more useful than General_Error. * Error Values ** Map ASSUAN error values. diff --git a/trunk/doc/ChangeLog b/trunk/doc/ChangeLog index 8d5a898..ed854aa 100644 --- a/trunk/doc/ChangeLog +++ b/trunk/doc/ChangeLog @@ -1,3 +1,8 @@ +2002-01-31 Marcus Brinkmann + + * gpgme.texi (Generating Keys): Document error at creation + failure. + 2002-01-30 Marcus Brinkmann * gpgme.texi (Deleting Keys): Document new error values. diff --git a/trunk/doc/gpgme.texi b/trunk/doc/gpgme.texi index 7287307..7e883e3 100644 --- a/trunk/doc/gpgme.texi +++ b/trunk/doc/gpgme.texi @@ -1472,8 +1472,9 @@ allowed. The function returns @code{GPGME_No_Error} if the operation could be started successfully, @code{GPGME_Invalid_Value} if @var{parms} is not -a valid XML string, and @code{GPGME_Not_Supported} if @var{pubkey} or -@var{seckey} is not @code{NULL}. +a valid XML string, @code{GPGME_Not_Supported} if @var{pubkey} or +@var{seckey} is not @code{NULL}, and @code{GPGME_General_Error} if no +key was created by the backend. @end deftypefun @deftypefun GpgmeError gpgme_op_genkey_start (@w{GpgmeCtx @var{ctx}}, @w{const char *@var{parms}}, @w{GpgmeData @var{pubkey}}, @w{GpgmeData @var{seckey}}) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 8b47b09..8f0f1e3 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,21 @@ +2002-01-31 Marcus Brinkmann + + * rungpg.h: Add STATUS_KEY_CREATED. + + * progress.c: New file. + * Makefile.am (libgpgme_la_SOURCES): Add progress.c. + + * genkey.c (genkey_status_handler): Use + _gpgme_progress_status_handler. Add check for status. + (struct genkey_result_s): New structure. + (_gpgme_release_genkey_result): New function. + (gpgme_op_genkey): Check for error. + * gpgme.c (_gpgme_release_result): Call + _gpgme_release_genkey_result. + * ops.h (_gpgme_release_genkey_result): Add prototype. + * types.h (GenKeyResult): New type. + * context.h (gpgme_context_s): Add GenKeyResult to member result. + 2002-01-30 Marcus Brinkmann * gpgme.c (_gpgme_release_result): Call diff --git a/trunk/gpgme/Makefile.am b/trunk/gpgme/Makefile.am index e6c1dd7..ffc808d 100644 --- a/trunk/gpgme/Makefile.am +++ b/trunk/gpgme/Makefile.am @@ -1,5 +1,5 @@ # Copyright (C) 2000 Werner Koch (dd9jn) -# Copyright (C) 2001 g10 Code GmbH +# Copyright (C) 2001, 2002 g10 Code GmbH # # This file is part of GPGME. # @@ -46,6 +46,7 @@ libgpgme_la_SOURCES = \ verify.c \ sign.c \ passphrase.c \ + progress.c \ key.c key.h \ keylist.c \ trustlist.c \ diff --git a/trunk/gpgme/context.h b/trunk/gpgme/context.h index ae2460b..9a467fe 100644 --- a/trunk/gpgme/context.h +++ b/trunk/gpgme/context.h @@ -1,6 +1,6 @@ /* context.h * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2002 g10 Code GmbH * * This file is part of GPGME. * @@ -70,6 +70,7 @@ struct gpgme_context_s { PassphraseResult passphrase; ImportResult import; DeleteResult delete; + GenKeyResult genkey; } result; GpgmeData notation; /* last signature notation */ @@ -136,9 +137,4 @@ struct gpgme_recipients_s { gpgme_wait ((c), 1); \ } while (0) - - #endif /* CONTEXT_H */ - - - diff --git a/trunk/gpgme/delete.c b/trunk/gpgme/delete.c index 23044c4..35ba0fe 100644 --- a/trunk/gpgme/delete.c +++ b/trunk/gpgme/delete.c @@ -1,5 +1,5 @@ /* delete.c - delete a key - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2002 g10 Code GmbH * * This file is part of GPGME. * diff --git a/trunk/gpgme/genkey.c b/trunk/gpgme/genkey.c index be52056..ca04b4e 100644 --- a/trunk/gpgme/genkey.c +++ b/trunk/gpgme/genkey.c @@ -1,6 +1,6 @@ /* genkey.c - key generation * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2002 g10 Code GmbH * * This file is part of GPGME. * @@ -29,39 +29,55 @@ #include "context.h" #include "ops.h" + +struct genkey_result_s +{ + int created_primary : 1; + int created_sub : 1; +}; + + +void +_gpgme_release_genkey_result (GenKeyResult result) +{ + if (!result) + return; + xfree (result); +} + static void -genkey_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args ) +genkey_status_handler (GpgmeCtx ctx, GpgStatusCode code, char *args) { - if ( code == STATUS_PROGRESS && *args ) { - if (ctx->progress_cb) { - char *p; - int type=0, current=0, total=0; - - if ( (p = strchr (args, ' ')) ) { - *p++ = 0; - if (*p) { - type = *(byte*)p; - if ( (p = strchr (p+1, ' ')) ) { - *p++ = 0; - if (*p) { - current = atoi (p); - if ( (p = strchr (p+1, ' ')) ) { - *p++ = 0; - total = atoi (p); - } - } - } - } - } - if ( type != 'X' ) - ctx->progress_cb ( ctx->progress_cb_value, args, type, - current, total ); + _gpgme_progress_status_handler (ctx, code, args); + + if (ctx->out_of_core) + return; + + if (!ctx->result.genkey) + { + ctx->result.genkey = xtrycalloc (1, sizeof *ctx->result.genkey); + if (!ctx->result.genkey) + { + ctx->out_of_core = 1; + return; } - return; } - DEBUG2 ("genkey_status: code=%d args=`%s'\n", code, args ); - /* FIXME: Need to do more */ + switch (code) + { + case STATUS_KEY_CREATED: + if (args && *args) + { + if (*args == 'B' || *args == 'P') + ctx->result.genkey->created_primary = 1; + if (*args == 'B' || *args == 'S') + ctx->result.genkey->created_sub = 1; + } + break; + + default: + break; + } } @@ -189,6 +205,7 @@ gpgme_op_genkey_start (GpgmeCtx ctx, const char *parms, return err; } + /** * gpgme_op_genkey: * @c: the context @@ -209,11 +226,15 @@ gpgme_op_genkey (GpgmeCtx ctx, const char *parms, { GpgmeError err = gpgme_op_genkey_start (ctx, parms, pubkey, seckey); if (!err) - gpgme_wait (ctx, 1); + { + gpgme_wait (ctx, 1); + + /* FIXME: Should return some more useful error value. */ + if (!ctx->result.genkey) + err = mk_error (General_Error); + else if (!ctx->result.genkey->created_primary + && !ctx->result.genkey->created_sub) + err = mk_error (General_Error); + } return err; } - - - - - diff --git a/trunk/gpgme/gpgme.c b/trunk/gpgme/gpgme.c index d528f8f..dbd620d 100644 --- a/trunk/gpgme/gpgme.c +++ b/trunk/gpgme/gpgme.c @@ -34,7 +34,7 @@ * @r_ctx: Returns the new context * * Create a new context to be used with most of the other GPGME - * functions. Use gpgme_release_contect() to release all resources + * functions. Use gpgme_release_context() to release all resources * * Return value: An error code **/ @@ -88,6 +88,7 @@ _gpgme_release_result (GpgmeCtx ctx) _gpgme_release_passphrase_result (ctx->result.passphrase); _gpgme_release_import_result (ctx->result.import); _gpgme_release_delete_result (ctx->result.delete); + _gpgme_release_genkey_result (ctx->result.genkey); memset (&ctx->result, 0, sizeof (ctx->result)); _gpgme_set_op_info (ctx, NULL); } diff --git a/trunk/gpgme/ops.h b/trunk/gpgme/ops.h index ed6e5db..7b6b90f 100644 --- a/trunk/gpgme/ops.h +++ b/trunk/gpgme/ops.h @@ -1,6 +1,6 @@ /* ops.h - internal operations stuff * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2002 g10 Code GmbH * * This file is part of GPGME. * @@ -95,15 +95,23 @@ void _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgStatusCode code, GpgmeError _gpgme_passphrase_start (GpgmeCtx ctx); GpgmeError _gpgme_passphrase_result (GpgmeCtx ctx); +/*-- progress.c --*/ +void _gpgme_progress_status_handler (GpgmeCtx ctx, GpgStatusCode code, + char *args); + /*-- import.c --*/ void _gpgme_release_import_result (ImportResult res); /*-- delete.c --*/ void _gpgme_release_delete_result (DeleteResult res); +/*-- genkey.c --*/ +void _gpgme_release_genkey_result (GenKeyResult res); + /*-- version.c --*/ const char *_gpgme_compare_versions (const char *my_version, const char *req_version); char *_gpgme_get_program_version (const char *const path); + #endif /* OPS_H */ diff --git a/trunk/gpgme/rungpg.h b/trunk/gpgme/rungpg.h index 3ca993c..9120a4d 100644 --- a/trunk/gpgme/rungpg.h +++ b/trunk/gpgme/rungpg.h @@ -48,7 +48,6 @@ typedef enum { STATUS_SHM_GET_BOOL , STATUS_SHM_GET_HIDDEN , STATUS_NEED_PASSPHRASE , - STATUS_USERID_HINT , STATUS_UNEXPECTED , STATUS_VALIDSIG , STATUS_SIG_ID , @@ -81,9 +80,11 @@ typedef enum { STATUS_GOT_IT , STATUS_PROGRESS , STATUS_SIG_CREATED , + STATUS_KEY_CREATED , STATUS_SESSION_KEY , STATUS_NOTATION_NAME , STATUS_NOTATION_DATA , + STATUS_USERID_HINT , STATUS_POLICY_URL , STATUS_BEGIN_STREAM , STATUS_END_STREAM , diff --git a/trunk/gpgme/types.h b/trunk/gpgme/types.h index 38f58f9..9ebdfe9 100644 --- a/trunk/gpgme/types.h +++ b/trunk/gpgme/types.h @@ -1,6 +1,6 @@ /* types.h - Some type definitions * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001 g10 Code GmbH + * Copyright (C) 2001, 2002 g10 Code GmbH * * This file is part of GPGME. * @@ -84,5 +84,9 @@ typedef struct import_result_s *ImportResult; struct delete_result_s; typedef struct delete_result_s *DeleteResult; +/*-- genkey.c --*/ +struct genkey_result_s; +typedef struct genkey_result_s *GenKeyResult; + #endif /* TYPES_H */