2002-01-31  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.texi (Generating Keys): Document error at creation
	failure.

gpgme/
2002-01-31  Marcus Brinkmann  <marcus@g10code.de>

	* 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.
This commit is contained in:
Marcus Brinkmann 2002-01-31 00:31:44 +00:00
parent ca5e3a09e3
commit 129da707d1
12 changed files with 109 additions and 51 deletions

4
TODO
View File

@ -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.

View File

@ -1,3 +1,8 @@
2002-01-31 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Generating Keys): Document error at creation
failure.
2002-01-30 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Deleting Keys): Document new error values.

View File

@ -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}})

View File

@ -1,3 +1,21 @@
2002-01-31 Marcus Brinkmann <marcus@g10code.de>
* 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 <marcus@g10code.de>
* gpgme.c (_gpgme_release_result): Call

View File

@ -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 \

View File

@ -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 */

View File

@ -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.
*

View File

@ -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"
static void
genkey_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
struct genkey_result_s
{
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 );
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)
{
_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;
}

View File

@ -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);
}

View File

@ -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 */

View File

@ -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 ,

View File

@ -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 */