(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.
+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.
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}})
+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
# 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.
#
verify.c \
sign.c \
passphrase.c \
+ progress.c \
key.c key.h \
keylist.c \
trustlist.c \
/* 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.
*
PassphraseResult passphrase;
ImportResult import;
DeleteResult delete;
+ GenKeyResult genkey;
} result;
GpgmeData notation; /* last signature notation */
gpgme_wait ((c), 1); \
} while (0)
-
-
#endif /* CONTEXT_H */
-
-
-
/* delete.c - delete a key
- * Copyright (C) 2001 g10 Code GmbH
+ * Copyright (C) 2001, 2002 g10 Code GmbH
*
* This file is part of GPGME.
*
/* 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.
*
#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;
+ }
}
return err;
}
+
/**
* gpgme_op_genkey:
* @c: the context
{
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;
}
-
-
-
-
-
* @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
**/
_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);
}
/* 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.
*
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 */
STATUS_SHM_GET_BOOL ,
STATUS_SHM_GET_HIDDEN ,
STATUS_NEED_PASSPHRASE ,
- STATUS_USERID_HINT ,
STATUS_UNEXPECTED ,
STATUS_VALIDSIG ,
STATUS_SIG_ID ,
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 ,
/* 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.
*
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 */