2003-04-27  Marcus Brinkmann  <marcus@g10code.de>

	* gpgme.texi (Deleting Keys): Document
	GPGME_Ambiguous_Specification.
	(Error Values): Remove GPGME_Invalid_Type and GPGME_Invalid_Mode.
	Add GPGME_Unknown_Reason, GPGME_Not_Found,
	GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
	GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
	GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
	GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
	GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
	GPGME_Bad_Signature, GPGME_No_Public_Key.

gpgme/
2003-04-27  Marcus Brinkmann  <marcus@g10code.de>

	* delete.c: Include <errno.h> and "gpgme.h", but not "util.h" or
	"key.h".
	(enum delete_problem): Move into function delete_status_handler.
	(delete_status_handler): Change first argument to void *.  Parse
	delete problem with strtol instead atoi.  Return better error
	values.
	(_gpgme_op_delete_start): Rename to ...
	(delete_start): ... this.  Rework error handling.
	(gpgme_op_delete_start): Use delete_start instead
	_gpgme_op_delete_start.
	(gpgme_op_delete): Likewise.
	* gpgme.h (GpgmeDataType): Removed.
This commit is contained in:
Marcus Brinkmann 2003-04-27 17:35:42 +00:00
parent ffa2b2158c
commit 2ffb03a969
6 changed files with 128 additions and 76 deletions

2
NEWS
View File

@ -107,7 +107,7 @@ GpgmeGenKeyResult NEW
gpgme_op_import_ext DEPRECATED: Use gpgme_op_import_result. gpgme_op_import_ext DEPRECATED: Use gpgme_op_import_result.
gpgme_op_import_result NEW gpgme_op_import_result NEW
GpgmeImportStatus NEW GpgmeImportStatus NEW
GPgmeImportResult NEW GpgmeImportResult NEW
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Noteworthy changes in version 0.4.0 (2002-12-23) Noteworthy changes in version 0.4.0 (2002-12-23)

View File

@ -1,3 +1,16 @@
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Deleting Keys): Document
GPGME_Ambiguous_Specification.
(Error Values): Remove GPGME_Invalid_Type and GPGME_Invalid_Mode.
Add GPGME_Unknown_Reason, GPGME_Not_Found,
GPGME_Ambiguous_Specification, GPGME_Wrong_Key_Usage,
GPGME_Key_Revoked, GPGME_Key_Expired, GPGME_No_CRL_Known,
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key.
2003-04-25 Marcus Brinkmann <marcus@g10code.de> 2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Importing Keys): Change GPGME_IMPORT_PRIVATE to * gpgme.texi (Importing Keys): Change GPGME_IMPORT_PRIVATE to

View File

@ -819,16 +819,6 @@ This value means that an I/O read operation failed.
@item GPGME_Write_Error @item GPGME_Write_Error
This value means that an I/O write operation failed. This value means that an I/O write operation failed.
@item GPGME_Invalid_Type
This value means that a user provided object was of a wrong or
incompatible type. Usually this refers to the type of a
@code{GpgmeData} object.
@item GPGME_Invalid_Mode
This value means that a @code{GpgmeData} object has an incorrect mode
of operation (for example, doesn't support output although it is
attempted to use it as an output buffer).
@item GPGME_File_Error @item GPGME_File_Error
This value means that a file I/O operation failed. The value of This value means that a file I/O operation failed. The value of
@var{errno} contains the system error value. @var{errno} contains the system error value.
@ -851,6 +841,61 @@ This value means that the engine that implements the desired protocol
is currently not available. This can either be because the sources is currently not available. This can either be because the sources
were configured to exclude support for this engine, or because the were configured to exclude support for this engine, or because the
engine is not installed properly. engine is not installed properly.
@item GPGME_Unknown_Reason
This value indicates that a user ID was invalid but the exact reason
is not specified.
@item GPGME_Not_Found
This value indicates that a user ID was not found.
@item GPGME_Ambiguous_Specification
This value indicates that a user ID did not specify a unique key.
@item GPGME_Wrong_Key_Usage
This value indicates that a key is not used appropriately.
@item GPGME_Key_Revoked
This value indicates that a key was revoced.
@item GPGME_Key_Expired
This value indicates that a key was expired.
@item GPGME_No_CRL_Known
This value indicates that no certificate revocation list is known for
the certificate.
@item GPGME_Policy_Mismatch
This value indicates that a policy issue occured.
@item GPGME_No_Secret_Key
This value indicates that no secret key for the user ID is available.
@item GPGME_Key_Not_Trusted
This value indicates that the key with the user ID is not trusted.
@item GPGME_Issuer_Missing
This value indicates that a key could not be imported because there is
no issuer
@item GPGME_Chain_Too_Long
This value indicates that a key could not be imported because its
certificate chain is too long.
@item GPGME_Unsupported_Algorithm
This value means a verification failed because the cryptographic
algorithm is not supported by the crypto backend.
@item GPGME_Sig_Expired
This value means a verification failed because the signature expired.
@item GPGME_Bad_Signature
This value means a verification failed because the signature is bad.
@item GPGME_No_Public_Key
This value means a verification failed because the public key is not
available.
@end table @end table
@end deftp @end deftp
@ -2416,8 +2461,9 @@ otherwise secret keys are deleted as well, if that is supported.
The function returns @code{GPGME_No_Error} if the key was deleted The function returns @code{GPGME_No_Error} if the key was deleted
successfully, @code{GPGME_Invalid_Value} if @var{ctx} or @var{key} is successfully, @code{GPGME_Invalid_Value} if @var{ctx} or @var{key} is
not a valid pointer, @code{GPGME_Invalid_Key} if @var{key} could not not a valid pointer, @code{GPGME_Invalid_Key} if @var{key} could not
be found in the keyring, and @code{GPGME_Conflict} if the secret key be found in the keyring, @code{GPGME_Ambiguous_Specification} if the
for @var{key} is available, but @var{allow_secret} is zero. key was not specified unambiguously, and @code{GPGME_Conflict} if the
secret key for @var{key} is available, but @var{allow_secret} is zero.
@end deftypefun @end deftypefun
@deftypefun GpgmeError gpgme_op_delete_start (@w{GpgmeCtx @var{ctx}}, @w{const GpgmeKey @var{key}}, @w{int @var{allow_secret}}) @deftypefun GpgmeError gpgme_op_delete_start (@w{GpgmeCtx @var{ctx}}, @w{const GpgmeKey @var{key}}, @w{int @var{allow_secret}})

View File

@ -1,3 +1,18 @@
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* delete.c: Include <errno.h> and "gpgme.h", but not "util.h" or
"key.h".
(enum delete_problem): Move into function delete_status_handler.
(delete_status_handler): Change first argument to void *. Parse
delete problem with strtol instead atoi. Return better error
values.
(_gpgme_op_delete_start): Rename to ...
(delete_start): ... this. Rework error handling.
(gpgme_op_delete_start): Use delete_start instead
_gpgme_op_delete_start.
(gpgme_op_delete): Likewise.
* gpgme.h (GpgmeDataType): Removed.
2003-04-25 Marcus Brinkmann <marcus@g10code.de> 2003-04-25 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h: Change GPGME_IMPORT_PRIVATE to GPGME_IMPORT_SECRET. * gpgme.h: Change GPGME_IMPORT_PRIVATE to GPGME_IMPORT_SECRET.
@ -11,7 +26,7 @@
GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key, GPGME_CRL_Too_Old, GPGME_Policy_Mismatch, GPGME_No_Secret_Key,
GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long, GPGME_Key_Not_Trusted, GPGME_Issuer_Missing, GPGME_Chain_Too_Long,
GPGME_Unsupported_Algorithm, GPGME_Sig_Expired, GPGME_Unsupported_Algorithm, GPGME_Sig_Expired,
GPGME_Bad_Signature, GPGME_No_Public_Key): New error codes. GPGME_Bad_Signature, GPGME_No_Public_Key added as new error codes.
(struct _gpgme_import_status): New structure. (struct _gpgme_import_status): New structure.
(GpgmeImportStatus): New type. (GpgmeImportStatus): New type.
(struct _gpgme_op_import_result): New structure. (struct _gpgme_op_import_result): New structure.

View File

@ -21,28 +21,33 @@
#include <config.h> #include <config.h>
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <errno.h>
#include "util.h" #include "gpgme.h"
#include "context.h" #include "context.h"
#include "ops.h" #include "ops.h"
#include "key.h"
enum delete_problem
{
DELETE_No_Problem = 0,
DELETE_No_Such_Key = 1,
DELETE_Must_Delete_Secret_Key = 2,
DELETE_Ambiguous_Specification = 3
};
static GpgmeError static GpgmeError
delete_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) delete_status_handler (void *priv, GpgmeStatusCode code, char *args)
{ {
if (code == GPGME_STATUS_DELETE_PROBLEM) if (code == GPGME_STATUS_DELETE_PROBLEM)
{ {
enum delete_problem problem = atoi (args); enum delete_problem
{
DELETE_No_Problem = 0,
DELETE_No_Such_Key = 1,
DELETE_Must_Delete_Secret_Key = 2,
DELETE_Ambiguous_Specification = 3
};
long problem;
char *tail;
errno = 0;
problem = strtol (args, &tail, 0);
if (errno || (*tail && *tail != ' '))
return GPGME_General_Error;
switch (problem) switch (problem)
{ {
case DELETE_No_Problem: case DELETE_No_Problem:
@ -55,7 +60,8 @@ delete_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
return GPGME_Conflict; return GPGME_Conflict;
case DELETE_Ambiguous_Specification: case DELETE_Ambiguous_Specification:
/* XXX Need better error value. Fall through. */ return GPGME_Ambiguous_Specification;
default: default:
return GPGME_General_Error; return GPGME_General_Error;
} }
@ -65,51 +71,36 @@ delete_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args)
static GpgmeError static GpgmeError
_gpgme_op_delete_start (GpgmeCtx ctx, int synchronous, delete_start (GpgmeCtx ctx, int synchronous, const GpgmeKey key,
const GpgmeKey key, int allow_secret) int allow_secret)
{ {
GpgmeError err = 0; GpgmeError err;
err = _gpgme_op_reset (ctx, synchronous); err = _gpgme_op_reset (ctx, synchronous);
if (err) if (err)
goto leave; return err;
_gpgme_engine_set_status_handler (ctx->engine, delete_status_handler, ctx); _gpgme_engine_set_status_handler (ctx->engine, delete_status_handler, ctx);
err = _gpgme_engine_op_delete (ctx->engine, key, allow_secret); return _gpgme_engine_op_delete (ctx->engine, key, allow_secret);
leave:
if (err)
{
_gpgme_engine_release (ctx->engine);
ctx->engine = NULL;
}
return err;
} }
/* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
keys are also deleted. */
GpgmeError GpgmeError
gpgme_op_delete_start (GpgmeCtx ctx, const GpgmeKey key, int allow_secret) gpgme_op_delete_start (GpgmeCtx ctx, const GpgmeKey key, int allow_secret)
{ {
return _gpgme_op_delete_start (ctx, 0, key, allow_secret); return delete_start (ctx, 0, key, allow_secret);
} }
/** /* Delete KEY from the keyring. If ALLOW_SECRET is non-zero, secret
* gpgme_op_delete: keys are also deleted. */
* @c: Context
* @key: A Key Object
* @allow_secret: Allow secret key delete
*
* Delete the give @key from the key database. To delete a secret
* along with the public key, @allow_secret must be true.
*
* Return value: 0 on success or an error code.
**/
GpgmeError GpgmeError
gpgme_op_delete (GpgmeCtx ctx, const GpgmeKey key, int allow_secret) gpgme_op_delete (GpgmeCtx ctx, const GpgmeKey key, int allow_secret)
{ {
GpgmeError err = _gpgme_op_delete_start (ctx, 1, key, allow_secret); GpgmeError err = delete_start (ctx, 1, key, allow_secret);
if (!err) if (!err)
err = _gpgme_wait_one (ctx); err = _gpgme_wait_one (ctx);
return err; return err;

View File

@ -86,16 +86,14 @@ typedef enum
GPGME_Not_Implemented = 0x0009, GPGME_Not_Implemented = 0x0009,
GPGME_Read_Error = 0x000a, GPGME_Read_Error = 0x000a,
GPGME_Write_Error = 0x000b, GPGME_Write_Error = 0x000b,
GPGME_Invalid_Type = 0x000c, GPGME_File_Error = 0x000c, /* errno is set in this case. */
GPGME_Invalid_Mode = 0x000d, GPGME_Decryption_Failed = 0x000d,
GPGME_File_Error = 0x000e, /* errno is set in this case. */ GPGME_Bad_Passphrase = 0x000e,
GPGME_Decryption_Failed = 0x000f, GPGME_Canceled = 0x000f,
GPGME_Bad_Passphrase = 0x0010, GPGME_Invalid_Key = 0x0010,
GPGME_Canceled = 0x0011, GPGME_Invalid_Engine = 0x0011,
GPGME_Invalid_Key = 0x0012, GPGME_No_UserID = 0x0012,
GPGME_Invalid_Engine = 0x0013, GPGME_Invalid_UserID = 0x0013,
GPGME_No_UserID = 0x0014,
GPGME_Invalid_UserID = 0x0015,
/* Reasons for invalid user id. */ /* Reasons for invalid user id. */
GPGME_Unknown_Reason = 0x0100, GPGME_Unknown_Reason = 0x0100,
@ -130,17 +128,6 @@ GpgmeError;
#define GPGME_Invalid_Recipient GPGME_Invalid_UserID #define GPGME_Invalid_Recipient GPGME_Invalid_UserID
#define GPGME_No_Passphrase GPGME_Bad_Passphrase #define GPGME_No_Passphrase GPGME_Bad_Passphrase
/* The possible types of GpgmeData objects. */
typedef enum
{
GPGME_DATA_TYPE_NONE = 0,
GPGME_DATA_TYPE_MEM = 1,
GPGME_DATA_TYPE_FD = 2,
GPGME_DATA_TYPE_FILE = 3,
GPGME_DATA_TYPE_CB = 4
}
GpgmeDataType;
/* The possible encoding mode of GpgmeData objects. */ /* The possible encoding mode of GpgmeData objects. */
typedef enum typedef enum
{ {